ariatosca-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mxm...@apache.org
Subject incubator-ariatosca git commit: removed shell=True [Forced Update!]
Date Tue, 27 Jun 2017 09:19:24 GMT
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-285-Cancel-execution-may-leave-running-processes 037106396 -> de0b05d39
(forced update)


removed shell=True


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/de0b05d3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/de0b05d3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/de0b05d3

Branch: refs/heads/ARIA-285-Cancel-execution-may-leave-running-processes
Commit: de0b05d39f6bc4fe8cc81b1ea4a285c9064981e4
Parents: 3d5efc4
Author: max-orlov <maxim@gigaspaces.com>
Authored: Tue Jun 27 11:53:40 2017 +0300
Committer: max-orlov <maxim@gigaspaces.com>
Committed: Tue Jun 27 12:19:18 2017 +0300

----------------------------------------------------------------------
 aria/orchestrator/workflows/executor/process.py | 20 +++++++++-----------
 .../workflows/executor/test_process_executor.py | 14 +++++---------
 2 files changed, 14 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/de0b05d3/aria/orchestrator/workflows/executor/process.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/workflows/executor/process.py b/aria/orchestrator/workflows/executor/process.py
index 92c83e3..40c0f32 100644
--- a/aria/orchestrator/workflows/executor/process.py
+++ b/aria/orchestrator/workflows/executor/process.py
@@ -125,14 +125,10 @@ class ProcessExecutor(base.BaseExecutor):
     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
-            # for the current session of the system, and killing it will kill the the entire
-            # os session.
-            os.killpg(os.getpgid(task.proc.pid), signal.SIGINT)
-
+        if task:
+            os.kill(task.proc.pid, signal.SIGINT)
             time.sleep(self._termination_timeout)
-            os.killpg(os.getpgid(task.proc.pid), signal.SIGTERM)
+            os.kill(task.proc.pid, signal.SIGKILL)
 
     def _execute(self, ctx):
         self._check_closed()
@@ -146,10 +142,12 @@ class ProcessExecutor(base.BaseExecutor):
         env = self._construct_subprocess_env(task=ctx.task)
         # Asynchronously start the operation in a subprocess
         proc = subprocess.Popen(
-            '{0} {1} {2}'.format(sys.executable, __file__, arguments_json_path),
-            env=env,
-            preexec_fn=os.setsid,
-            shell=True)
+            [
+                sys.executable,
+                os.path.expanduser(os.path.expandvars(__file__)),
+                os.path.expanduser(os.path.expandvars(arguments_json_path))
+            ],
+            env=env)
 
         self._tasks[ctx.task.id] = _Task(ctx=ctx, proc=proc)
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/de0b05d3/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 be3e833..8b778a3 100644
--- a/tests/orchestrator/workflows/executor/test_process_executor.py
+++ b/tests/orchestrator/workflows/executor/test_process_executor.py
@@ -16,11 +16,9 @@
 import os
 import time
 import Queue
-import subprocess
 
 import pytest
 import psutil
-import retrying
 
 import aria
 from aria import operation
@@ -90,15 +88,13 @@ class TestProcessExecutor(object):
 
         executor.execute(ctx)
 
-        while fs_test_holder.get('subproc', None) is None:
+        while fs_test_holder.get('started', False) is False:
             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)
+        pid = executor._tasks[ctx.task.id].proc.pid
+        assert any(p.pid == pid for p in psutil.process_iter())
         executor.terminate(ctx.task.id)
-        time.sleep(10)
         assert not any(p.pid == pid and p.status() != psutil.STATUS_ZOMBIE
-                       for p in psutil.process_iter()
-                       for pid in pids)
+                       for p in psutil.process_iter())
 
 
 @pytest.fixture
@@ -136,6 +132,6 @@ def model(tmpdir):
 @operation
 def freezing_task(holder_path, **_):
     holder = FilesystemDataHolder(holder_path)
-    holder['subproc'] = subprocess.Popen('while true; do sleep 5; done', shell=True).pid
+    holder['started'] = True
     while True:
         time.sleep(5)


Mime
View raw message