diff options
Diffstat (limited to 'yardstick/benchmark/runners/base.py')
-rwxr-xr-x | yardstick/benchmark/runners/base.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/yardstick/benchmark/runners/base.py b/yardstick/benchmark/runners/base.py index d443806a7..9925ace2f 100755 --- a/yardstick/benchmark/runners/base.py +++ b/yardstick/benchmark/runners/base.py @@ -141,13 +141,20 @@ class Runner(object): @staticmethod def release(runner): '''Release the runner''' - Runner.runners.remove(runner) + if runner in Runner.runners: + Runner.runners.remove(runner) # if this was the last runner, stop the output serializer subprocess if len(Runner.runners) == 0: Runner.release_dump_process() @staticmethod + def terminate(runner): + '''Terminate the runner''' + if runner.process and runner.process.is_alive(): + runner.process.terminate() + + @staticmethod def terminate_all(): '''Terminate all runners (subprocesses)''' log.debug("Terminating all runners") @@ -173,6 +180,7 @@ class Runner(object): self.periodic_action_process = None self.result_queue = queue self.process = None + self.aborted = multiprocessing.Event() Runner.runners.append(self) def run_post_stop_action(self): @@ -197,6 +205,7 @@ class Runner(object): cls = getattr(module, path_split[-1]) self.config['object'] = class_name + self.aborted.clear() # run a potentially configured pre-start action if "pre-start-action" in self.config: @@ -230,8 +239,12 @@ class Runner(object): self._run_benchmark(cls, "run", scenario_cfg, context_cfg) - def join(self): - self.process.join() + def abort(self): + '''Abort the execution of a scenario''' + self.aborted.set() + + def join(self, timeout=None): + self.process.join(timeout) if self.periodic_action_process: self.periodic_action_process.terminate() self.periodic_action_process = None |