From 18cd06004d6def9f11f01fef8a7fe21e51f46065 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=20Kr=C3=BCger?= Date: Mon, 7 Dec 2020 01:32:09 +0100 Subject: [PATCH] implemented feature to call a function after the experiment is done --- al2/experiment.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/al2/experiment.py b/al2/experiment.py index f25d355..be1a5ab 100644 --- a/al2/experiment.py +++ b/al2/experiment.py @@ -43,6 +43,8 @@ class Dispatcher (threading.Thread): self.__workers = [] self.__stop_called = threading.Event() + self.__exp_mod = exp_mod + for i in range(self.__num_workers): self.__workers.append(Worker(exp_mod, exp_plan)) @@ -72,6 +74,8 @@ class Dispatcher (threading.Thread): for worker in self.__workers: worker.join() + self.__done() + def stop(self): self.__stop_called.set() @@ -82,6 +86,11 @@ class Dispatcher (threading.Thread): return count + def __done(self): + if hasattr(self.__exp_mod, "done"): + self.__exp_mod.done() + + class Worker (multiprocessing.Process): def __init__(self, exp_mod, exp_plan): multiprocessing.Process.__init__(self)