2
0
mirror of https://github.com/m-labs/artiq.git synced 2024-12-25 03:08:27 +08:00

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

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