Skip to content

Commit

Permalink
worker: close devices immediately after run and before analyze
Browse files Browse the repository at this point in the history
  • Loading branch information
sbourdeauducq committed Mar 20, 2015
1 parent 577754c commit 200e20f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion artiq/frontend/artiq_run.py
Expand Up @@ -178,7 +178,7 @@ def main():
key=itemgetter(0)):
print("{}: {}".format(k, v))
finally:
dbh.close()
dbh.close_devices()

if __name__ == "__main__":
main()
10 changes: 3 additions & 7 deletions artiq/master/worker_db.py
Expand Up @@ -104,16 +104,12 @@ def get_device(self, name):
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()
3 changes: 2 additions & 1 deletion artiq/master/worker_impl.py
Expand Up @@ -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()
Expand All @@ -130,7 +131,7 @@ def main():
elif action == "terminate":
break
finally:
dbh.close()
dbh.close_devices()

if __name__ == "__main__":
main()

0 comments on commit 200e20f

Please sign in to comment.