From 7ad0724f0eba5d23819802b5820606c7bb683dfd Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 1 Jul 2018 19:35:23 +0200 Subject: [PATCH] while True loop for recording --- platypush/backend/camera/pi.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/platypush/backend/camera/pi.py b/platypush/backend/camera/pi.py index 25c52f2d8..94f0a9dbf 100644 --- a/platypush/backend/camera/pi.py +++ b/platypush/backend/camera/pi.py @@ -118,23 +118,24 @@ class CameraPiBackend(Backend): while True: self.camera.wait_recording(2) else: - connection = self.server_socket.accept()[0].makefile('wb') - self.logger.info('Accepted client connection on port {}'. - format(self.listen_port)) + while True: + connection = self.server_socket.accept()[0].makefile('wb') + self.logger.info('Accepted client connection on port {}'. + format(self.listen_port)) - try: - self.camera.start_recording(connection, format=format) - while True: - self.camera.wait_recording(2) - except ConnectionError: - self.logger.info('Client closed connection') try: - self.stop_recording() - connection.close() - except: - pass + self.camera.start_recording(connection, format=format) + while True: + self.camera.wait_recording(2) + except ConnectionError: + self.logger.info('Client closed connection') + try: + self.stop_recording() + connection.close() + except: + pass - self.send_camera_action(self.CameraAction.START_RECORDING) + self.send_camera_action(self.CameraAction.START_RECORDING) self._recording_thread = None