Commit 6393f62f authored by Xavier Thompson's avatar Xavier Thompson

SlapPopen: Wait until timed-out process is killed

parent 8a3beac1
...@@ -193,7 +193,9 @@ class SlapPopen(subprocess.Popen): ...@@ -193,7 +193,9 @@ class SlapPopen(subprocess.Popen):
try: try:
self.wait(timeout=timeout) self.wait(timeout=timeout)
except subprocess.TimeoutExpired as e: except subprocess.TimeoutExpired as e:
killProcessTree(self.pid, logger) for p in killProcessTree(self.pid, logger):
p.wait(timeout=10) # arbitrary timeout, wait until process is killed
self.poll() # set returncode (and avoid still-running warning)
e.output = e.stdout = ''.join(buffers.get(stdout_fileno, ())) e.output = e.stdout = ''.join(buffers.get(stdout_fileno, ()))
e.stderr = ''.join(buffers.get(stderr_fileno, ())) e.stderr = ''.join(buffers.get(stderr_fileno, ()))
raise raise
...@@ -486,7 +488,7 @@ def killProcessTree(pid, logger): ...@@ -486,7 +488,7 @@ def killProcessTree(pid, logger):
process = psutil.Process(pid) process = psutil.Process(pid)
process.suspend() process.suspend()
except psutil.Error: except psutil.Error:
return return ()
process_list = [process] process_list = [process]
running_process_list = process.children(recursive=True) running_process_list = process.children(recursive=True)
...@@ -506,3 +508,5 @@ def killProcessTree(pid, logger): ...@@ -506,3 +508,5 @@ def killProcessTree(pid, logger):
process.kill() process.kill()
except psutil.Error as e: except psutil.Error as e:
logger.debug("Process kill: %s" % e) logger.debug("Process kill: %s" % e)
return process_list
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment