From 2ae77bd231a083fb70f0fea177fe12cd2cab7c8b Mon Sep 17 00:00:00 2001 From: enegaard Date: Wed, 10 Nov 2021 08:14:16 +0100 Subject: [PATCH] Fix rpi_camera setup hanging on initialization (#59316) --- homeassistant/components/rpi_camera/camera.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/rpi_camera/camera.py b/homeassistant/components/rpi_camera/camera.py index 980586d4def..89fe7fe55d8 100644 --- a/homeassistant/components/rpi_camera/camera.py +++ b/homeassistant/components/rpi_camera/camera.py @@ -119,10 +119,13 @@ class RaspberryCamera(Camera): cmd_args.append("-a") cmd_args.append(str(device_info[CONF_OVERLAY_TIMESTAMP])) - with subprocess.Popen( + # The raspistill process started below must run "forever" in + # the background until killed when Home Assistant is stopped. + # Therefore it must not be wrapped with "with", since that + # waits for the subprocess to exit before continuing. + subprocess.Popen( # pylint: disable=consider-using-with cmd_args, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT - ): - pass + ) def camera_image( self, width: int | None = None, height: int | None = None