Fixed broken context manager __exit__

This commit is contained in:
Joel Collins 2018-11-06 18:49:44 +00:00
parent 028596a80e
commit a7499fa3be
2 changed files with 3 additions and 10 deletions

View file

@ -100,20 +100,12 @@ class StreamingCamera(BaseCamera):
# HANDLE CONTEXT MANAGER AND FILE CLOSING
def close(self):
"""Close method called by BaseCamera __exit__"""
# Close all StreamObjects
#TODO: Figure out why this is so slow.
for capture_list in [self.images, self.videos]:
for stream_object in capture_list:
stream_object.close()
def __enter__(self):
log("Entering context for {}.\
Stored files will be cleaned up automatically.".format(self))
return self
def __exit__(self, *args):
log("Cleaning up {}".format(self))
self.close()
self.stop_worker()
# RETURNING CAPTURES