Better events orchestration on camera.pi backend

This commit is contained in:
Fabio Manganiello 2018-06-14 00:44:50 +02:00
parent bb43facee5
commit 85512424ae

View file

@ -72,7 +72,8 @@ class CameraPiBackend(Backend):
super().run() super().run()
while True: 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') self.logger.info('Starting camera recording')
connection = self.server_socket.accept()[0].makefile('wb') connection = self.server_socket.accept()[0].makefile('wb')
@ -82,9 +83,11 @@ class CameraPiBackend(Backend):
self.stop_recording_event.wait() self.stop_recording_event.wait()
self.logger.info('Stopping camera recording') self.logger.info('Stopping camera recording')
except ConnectionError as e: except ConnectionError as e:
pass self.logger.info('Client {} closed connection'.format(connection))
finally: finally:
connection.close() try: connection.close()
except: pass
self.camera.stop_recording() self.camera.stop_recording()