DBHub: make it a context manager

This commit is contained in:
Robert Jördens 2015-04-04 20:40:31 -06:00
parent afc3982555
commit 7b86138fd2
1 changed files with 8 additions and 1 deletions

View File

@ -112,4 +112,11 @@ class DBHub:
dev.close_rpc()
elif hasattr(dev, "close"):
dev.close()
self.active_devices = OrderedDict()
self.active_devices.clear()
def __enter__(self):
return self
def __exit__(self, exc_type, exc_val, exc_tb):
self.close_devices()
return False # do not suppress exceptions within context