diff --git a/artiq/master/worker_db.py b/artiq/master/worker_db.py index e10266f5f..962a62de8 100644 --- a/artiq/master/worker_db.py +++ b/artiq/master/worker_db.py @@ -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