[Piuparts-commits] [SCM] piuparts git repository branch, develop, updated. 0.44-792-ge089177
Andreas Beckmann
debian at abeckmann.de
Mon Jun 18 21:35:18 UTC 2012
The following commit has been merged in the develop branch:
commit 38ad918eabbe5107f5cc7b0c006f34f61dec183a
Author: Andreas Beckmann <debian at abeckmann.de>
Date: Fri Jun 15 19:10:37 2012 +0200
p-s: factor out terminate_subprocess()
Signed-off-by: Andreas Beckmann <debian at abeckmann.de>
diff --git a/piuparts-slave.py b/piuparts-slave.py
index b8b59ea..f4eb264 100644
--- a/piuparts-slave.py
+++ b/piuparts-slave.py
@@ -447,6 +447,18 @@ def get_process_children(pid):
return [int(p) for p in stdout.split()]
def run_test_with_timeout(cmd, maxwait, kill_all=True):
+
+ def terminate_subprocess(p, kill_all):
+ pids = [p.pid]
+ if kill_all:
+ pids.extend(get_process_children(p.pid))
+ for pid in pids:
+ if pid > 0:
+ try:
+ os.kill(pid, SIGKILL)
+ except OSError:
+ pass
+
logging.debug("Executing: %s" % " ".join(cmd))
stdout = ""
@@ -459,16 +471,8 @@ def run_test_with_timeout(cmd, maxwait, kill_all=True):
stdout, stderr = p.communicate()
alarm(0)
except Alarm:
- pids = [p.pid]
- if kill_all:
- pids.extend(get_process_children(p.pid))
- for pid in pids:
- if pid > 0:
- try:
- os.kill(pid, SIGKILL)
- except OSError:
- pass
- return -1,stdout
+ terminate_subprocess(p, kill_all)
+ return -1,stdout
return p.returncode,stdout
--
piuparts git repository
More information about the Piuparts-commits
mailing list