Camera local_file - getting Bad File Descriptor Error - help needed


I’m getting infrequent erorrs while using the camera.local_file component.

ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.140154635488560] Error handling message: {'type': 'camera_thumbnail', 'entity_id': 'camera.local_file', 'id': 12493}
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/components/websocket_api/", line 17, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/app/homeassistant/components/camera/", line 463, in websocket_camera_thumbnail
    image = await async_get_image(hass, msg['entity_id'])
  File "/usr/src/app/homeassistant/components/camera/", line 93, in async_get_image
    image = await camera.async_camera_image()
  File "/usr/local/lib/python3.6/concurrent/futures/", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/camera/", line 72, in camera_image
    with open(self._file_path, 'rb') as file:
OSError: [Errno 9] Bad file descriptor

this is my config:

  - platform: local_file
    file_path: /config/tmp/latest.jpg

I’m scanning a camera picture via tensorflow for persons (via a motion trigger), and when a person is detected the picture is beeing saved:

  - platform: tensorflow
    scan_interval: 20000
      - entity_id: camera.test
      graph: /config/tensorflow/frozen_inference_graph.pb
        - person
      - "/config/tmp/latest.jpg"

Has anyone experienced the same and may point me in the right direction?
I’m running HA in a Docker on my NAS with 2.4Ghz QuadCore and 16MB Ram, performance should not be an issue.


Maybe try specifying the full pathname for the file…
That’s what I have for my camera and it works.

Thank you for your reply!
It is actually working, the file gets saved and can be read, but from time to time (still elaborating on the root cause) I get the ERROR mentioned above. So I assume the path is correct and accesible from HA.
What I am thinking about right now is that it may be due to simultaneous access
image_processing writes jpg and at the same time camera.local_file tries to load the file…

I’ve verified that the paths are accessible and there are no race conditions regarding “tensorflow image processing” causing this.

Related Issue on GitHub