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:
parent
afc3982555
commit
7b86138fd2
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user