implemented feature to call a function after the experiment is done
This commit is contained in:
@@ -43,6 +43,8 @@ class Dispatcher (threading.Thread):
|
|||||||
self.__workers = []
|
self.__workers = []
|
||||||
self.__stop_called = threading.Event()
|
self.__stop_called = threading.Event()
|
||||||
|
|
||||||
|
self.__exp_mod = exp_mod
|
||||||
|
|
||||||
for i in range(self.__num_workers):
|
for i in range(self.__num_workers):
|
||||||
self.__workers.append(Worker(exp_mod, exp_plan))
|
self.__workers.append(Worker(exp_mod, exp_plan))
|
||||||
|
|
||||||
@@ -72,6 +74,8 @@ class Dispatcher (threading.Thread):
|
|||||||
for worker in self.__workers:
|
for worker in self.__workers:
|
||||||
worker.join()
|
worker.join()
|
||||||
|
|
||||||
|
self.__done()
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self.__stop_called.set()
|
self.__stop_called.set()
|
||||||
|
|
||||||
@@ -82,6 +86,11 @@ class Dispatcher (threading.Thread):
|
|||||||
|
|
||||||
return count
|
return count
|
||||||
|
|
||||||
|
def __done(self):
|
||||||
|
if hasattr(self.__exp_mod, "done"):
|
||||||
|
self.__exp_mod.done()
|
||||||
|
|
||||||
|
|
||||||
class Worker (multiprocessing.Process):
|
class Worker (multiprocessing.Process):
|
||||||
def __init__(self, exp_mod, exp_plan):
|
def __init__(self, exp_mod, exp_plan):
|
||||||
multiprocessing.Process.__init__(self)
|
multiprocessing.Process.__init__(self)
|
||||||
|
Reference in New Issue
Block a user