forked from M-Labs/artiq
1
0
Fork 0

devices: introduce notify_run_end API

This commit is contained in:
Sebastien Bourdeauducq 2023-12-13 14:27:04 +08:00
parent 795c4372fa
commit ede0b37c6e
5 changed files with 12 additions and 0 deletions

View File

@ -222,6 +222,7 @@ def run(with_file=False):
exp_inst = _build_experiment(device_mgr, dataset_mgr, args)
exp_inst.prepare()
exp_inst.run()
device_mgr.notify_run_end()
exp_inst.analyze()
except CompileError as error:
return

View File

@ -804,6 +804,7 @@ def main():
experiment = SinaraTester((device_mgr, None, None, None))
experiment.prepare()
experiment.run(tests)
device_mgr.notify_run_end()
experiment.analyze()
finally:
device_mgr.close_devices()

View File

@ -92,6 +92,13 @@ class DeviceManager:
self.active_devices.append((desc, dev))
return dev
def notify_run_end(self):
"""Sends a "end of Experiment run stage" notification to
all active devices."""
for _desc, dev in self.active_devices:
if hasattr(dev, "notify_run_end"):
dev.notify_run_end()
def close_devices(self):
"""Closes all active devices, in the opposite order as they were
requested."""

View File

@ -343,6 +343,8 @@ def main():
# for end of analyze stage.
write_results()
raise
finally:
device_mgr.notify_run_end()
put_completed()
elif action == "analyze":
try:

View File

@ -55,6 +55,7 @@ class ExperimentCase(unittest.TestCase):
try:
exp = self.create(cls, *args, **kwargs)
exp.run()
self.device_mgr.notify_run_end()
exp.analyze()
return exp
except CompileError as error: