diff --git a/boxmox/experiment.py b/boxmox/experiment.py index f90c5d562336382e4455a36f6236887264b96471..dd65d0f80494b1242785aa8e362eee60e0c9cb89 100644 --- a/boxmox/experiment.py +++ b/boxmox/experiment.py @@ -114,6 +114,7 @@ class Experiment: self.lastLog = None self.pid = None + self.thread = None self.__new() @@ -192,10 +193,10 @@ class Experiment: ''' Check if simulation is running (if started with asynchronous=True). ''' - if self.pid is None: + if self.thread is None: return False else: - return self.pid.poll() is None + return self.thread.isAlive() def _run(self, dumbOutput=False): try: @@ -225,8 +226,8 @@ class Experiment: os.chdir(self.path) if asynchronous: - thread = threading.Thread(target=self._run, args=(dumbOutput,)) - thread.start() + self.thread = threading.Thread(target=self._run, args=(dumbOutput,)) + self.thread.start() os.chdir(pwd) return else: @@ -320,6 +321,7 @@ class ExperimentFromExample(Experiment): self.lastLog = None self.pid = None + self.thread = None self.input = {} self.output = {} @@ -362,6 +364,7 @@ class ExperimentFromExistingRun(Experiment): self.lastLog = None self.pid = None + self.thread = None self.input = {} self.output = {}