From 200e20fb39393c8f4c33d18dff5c31a61022153f Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Fri, 20 Mar 2015 12:01:34 +0100 Subject: [PATCH] worker: close devices immediately after run and before analyze --- artiq/frontend/artiq_run.py | 2 +- artiq/master/worker_db.py | 10 +++------- artiq/master/worker_impl.py | 3 ++- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/artiq/frontend/artiq_run.py b/artiq/frontend/artiq_run.py index 76f2cbc4b..315a154fc 100755 --- a/artiq/frontend/artiq_run.py +++ b/artiq/frontend/artiq_run.py @@ -178,7 +178,7 @@ def main(): key=itemgetter(0)): print("{}: {}".format(k, v)) finally: - dbh.close() + dbh.close_devices() if __name__ == "__main__": main() diff --git a/artiq/master/worker_db.py b/artiq/master/worker_db.py index 10037d457..e10266f5f 100644 --- a/artiq/master/worker_db.py +++ b/artiq/master/worker_db.py @@ -104,16 +104,12 @@ class DBHub: self.active_devices[name] = dev return dev - def close(self): + def close_devices(self): """Closes all active devices, in the opposite order as they were - requested. - - Do not use the same ``DBHub`` again after calling - this function. - - """ + requested.""" for dev in reversed(list(self.active_devices.values())): if isinstance(dev, (Client, BestEffortClient)): dev.close_rpc() elif hasattr(dev, "close"): dev.close() + self.active_devices = OrderedDict() diff --git a/artiq/master/worker_impl.py b/artiq/master/worker_impl.py index aa788a2f1..9b3e593f6 100644 --- a/artiq/master/worker_impl.py +++ b/artiq/master/worker_impl.py @@ -116,6 +116,7 @@ def main(): put_object({"action": "completed"}) elif action == "run": exp_inst.run() + dbh.close_devices() put_object({"action": "completed"}) elif action == "analyze": exp_inst.analyze() @@ -130,7 +131,7 @@ def main(): elif action == "terminate": break finally: - dbh.close() + dbh.close_devices() if __name__ == "__main__": main()