Browse Source

implemented feature to call a function after the experiment is done

master
Tom Krüger 4 years ago
parent
commit
18cd06004d
1 changed files with 9 additions and 0 deletions
  1. +9
    -0
      al2/experiment.py

+ 9
- 0
al2/experiment.py View File

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


Loading…
Cancel
Save