forked from platypush/platypush
[Camera] The wait_for_either
barrier should be enabled on streaming by default.
`camera.pi*` plugins are an exception, as they handle the lifecycle of the camera streaming process through the `picamera*` libraries. Otherwise, the streaming thread should explicitly wait on either the plugin stop or streaming stop events and exit accordingly, or the camera thread may be streaming indefinitely.
This commit is contained in:
parent
56a04975ae
commit
e58f5d2fa1
1 changed files with 7 additions and 0 deletions
|
@ -770,6 +770,12 @@ class CameraPlugin(RunnablePlugin, ABC):
|
|||
|
||||
self.logger.info('Stopped camera stream')
|
||||
|
||||
def _wait_stream_stop(self, camera: Camera):
|
||||
try:
|
||||
wait_for_either(self._should_stop, camera.stop_stream_event)
|
||||
except Exception as e:
|
||||
self.logger.debug('Error on streaming poll: %s', e)
|
||||
|
||||
def _streaming_loop(
|
||||
self,
|
||||
camera: Camera,
|
||||
|
@ -785,6 +791,7 @@ class CameraPlugin(RunnablePlugin, ABC):
|
|||
assert camera.stream, 'No camera stream available'
|
||||
camera.stream.sock = sock
|
||||
self.start_camera(camera, duration=duration, frames_dir=None, image_file=None)
|
||||
self._wait_stream_stop(camera)
|
||||
|
||||
def _cleanup_stream(
|
||||
self, camera: Camera, server_socket: socket.socket, client: Optional[IO]
|
||||
|
|
Loading…
Reference in a new issue