From 85512424ae5ae022e6b4748b41071cb321b13625 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Thu, 14 Jun 2018 00:44:50 +0200 Subject: [PATCH] Better events orchestration on camera.pi backend --- platypush/backend/camera/pi.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/platypush/backend/camera/pi.py b/platypush/backend/camera/pi.py index 47ef43061..a6c74ad32 100644 --- a/platypush/backend/camera/pi.py +++ b/platypush/backend/camera/pi.py @@ -72,7 +72,8 @@ class CameraPiBackend(Backend): super().run() while True: - self.start_recording_event.wait() + if not self.start_recording_event.is_set(): + self.start_recording_event.wait() self.logger.info('Starting camera recording') connection = self.server_socket.accept()[0].makefile('wb') @@ -82,9 +83,11 @@ class CameraPiBackend(Backend): self.stop_recording_event.wait() self.logger.info('Stopping camera recording') except ConnectionError as e: - pass + self.logger.info('Client {} closed connection'.format(connection)) finally: - connection.close() + try: connection.close() + except: pass + self.camera.stop_recording()