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
1 changed files with 6 additions and 3 deletions

View File

@ -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()