From 6ab0fb0bf4fe7aae758f7146bd699c95b09171f2 Mon Sep 17 00:00:00 2001 From: "Christoph.Knote" <christoph.knote@physik.uni-muenchen.de> Date: Thu, 14 Dec 2017 15:43:28 +0100 Subject: [PATCH] Using thread to determine running, isntead of Popen. --- boxmox/experiment.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/boxmox/experiment.py b/boxmox/experiment.py index f90c5d5..dd65d0f 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 = {} -- GitLab