Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-285-Cancel-execution-may-leave-running-processes 9ff17e744 -> 9d2059982 (forced update)
terminating by task_id Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/9d205998 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/9d205998 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/9d205998 Branch: refs/heads/ARIA-285-Cancel-execution-may-leave-running-processes Commit: 9d20599829e2c57063f578be97cc81366a049941 Parents: 27ede8b Author: max-orlov <[email protected]> Authored: Sun Jun 25 17:04:09 2017 +0300 Committer: max-orlov <[email protected]> Committed: Sun Jun 25 17:29:24 2017 +0300 ---------------------------------------------------------------------- aria/orchestrator/workflows/core/engine.py | 2 +- aria/orchestrator/workflows/executor/process.py | 5 ++--- tests/orchestrator/workflows/executor/test_process_executor.py | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9d205998/aria/orchestrator/workflows/core/engine.py ---------------------------------------------------------------------- diff --git a/aria/orchestrator/workflows/core/engine.py b/aria/orchestrator/workflows/core/engine.py index 373abb8..5d6fcd7 100644 --- a/aria/orchestrator/workflows/core/engine.py +++ b/aria/orchestrator/workflows/core/engine.py @@ -80,7 +80,7 @@ class Engine(logger.LoggerMixin): def _terminate_tasks(self, tasks): for task in tasks: - self._executors[task._executor].terminate(task) + self._executors[task._executor].terminate(task.id) @staticmethod def cancel_execution(ctx): http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9d205998/aria/orchestrator/workflows/executor/process.py ---------------------------------------------------------------------- diff --git a/aria/orchestrator/workflows/executor/process.py b/aria/orchestrator/workflows/executor/process.py index 56241f6..0600b6a 100644 --- a/aria/orchestrator/workflows/executor/process.py +++ b/aria/orchestrator/workflows/executor/process.py @@ -120,9 +120,8 @@ class ProcessExecutor(base.BaseExecutor): self._server_socket.close() self._listener_thread.join(timeout=60) - def terminate(self, task): - # We need to retrieve the wrapped task (which includes the proc and the ctx) - task = self._tasks.get(task.id) + def terminate(self, task_id): + task = self._tasks.get(task_id) # The process might have managed to finished so it would not be in the tasks list if task and os.getsid(os.getpid()) != os.getpgid(task.proc.pid): # If the above condition is false, the process group leader is the group leader http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9d205998/tests/orchestrator/workflows/executor/test_process_executor.py ---------------------------------------------------------------------- diff --git a/tests/orchestrator/workflows/executor/test_process_executor.py b/tests/orchestrator/workflows/executor/test_process_executor.py index 2303fa9..963b7a8 100644 --- a/tests/orchestrator/workflows/executor/test_process_executor.py +++ b/tests/orchestrator/workflows/executor/test_process_executor.py @@ -93,7 +93,7 @@ class TestProcessExecutor(object): time.sleep(1) pids = [executor._tasks[ctx.task.id].proc.pid, fs_test_holder['subproc']] assert any(p.pid == pid for p in psutil.process_iter() for pid in pids) - executor.terminate(ctx) + executor.terminate(ctx.task.id) assert not any(p.pid == pid and p.status() != psutil.STATUS_ZOMBIE for p in psutil.process_iter() for pid in pids)
