Fixed broken context manager __exit__
This commit is contained in:
parent
028596a80e
commit
a7499fa3be
2 changed files with 3 additions and 10 deletions
|
|
@ -226,6 +226,7 @@ class StreamObject(object):
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
"""Both clear the stream, and delete any associated on-disk data"""
|
"""Both clear the stream, and delete any associated on-disk data"""
|
||||||
|
log("Closing {}".format(self.id))
|
||||||
self.delete_stream()
|
self.delete_stream()
|
||||||
if not self.keep_on_disk:
|
if not self.keep_on_disk:
|
||||||
self.delete_file()
|
self.delete_file()
|
||||||
|
|
|
||||||
|
|
@ -100,20 +100,12 @@ class StreamingCamera(BaseCamera):
|
||||||
# HANDLE CONTEXT MANAGER AND FILE CLOSING
|
# HANDLE CONTEXT MANAGER AND FILE CLOSING
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
|
"""Close method called by BaseCamera __exit__"""
|
||||||
# Close all StreamObjects
|
# Close all StreamObjects
|
||||||
#TODO: Figure out why this is so slow.
|
|
||||||
for capture_list in [self.images, self.videos]:
|
for capture_list in [self.images, self.videos]:
|
||||||
for stream_object in capture_list:
|
for stream_object in capture_list:
|
||||||
stream_object.close()
|
stream_object.close()
|
||||||
|
self.stop_worker()
|
||||||
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()
|
|
||||||
|
|
||||||
# RETURNING CAPTURES
|
# RETURNING CAPTURES
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue