forked from M-Labs/artiq
1
0
Fork 0

worker: close devices immediately after run and before analyze

This commit is contained in:
Sebastien Bourdeauducq 2015-03-20 12:01:34 +01:00
parent 577754c38f
commit 200e20fb39
3 changed files with 6 additions and 9 deletions

View File

@ -178,7 +178,7 @@ def main():
key=itemgetter(0)):
print("{}: {}".format(k, v))
finally:
dbh.close()
dbh.close_devices()
if __name__ == "__main__":
main()

View File

@ -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()

View File

@ -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()