Commit 34cb7879 authored by Kirill Smelkov's avatar Kirill Smelkov

Stop spawned process softly on ctx cancel

In 0ad45a9c (Detect if a test leaks processes and terminate them) we
organized waiting for spawned processes with handing ctx and sending
SIGKILL to the main spawned process on ctx cancel even though other
leaked processes are always first sent with SIGTERM and - only after
shutdown timeout - later with SIGKILL.

This is too brutal. Rework the code to first send SIGTERM to the main
spawned test process too, and leverage SIGKILL only later after shutdown

This will be tested in a later patch which exercises how cancel from
master is propagated.

/reviewed-by @jerome
/reviewed-on !14
parent 4fe9ee16
......@@ -269,25 +269,27 @@ def main():
if done is not None:
# cancel -> kill p
# cancel -> terminate p
_, _rx = select(
default, # 0
ctx.done().recv, # 1
if _ == 1:
# p is done - check if it leaked processes and kill them
# p should be done - check if it leaked processes and terminate/kill them
# kill p in the end if it does not stop from just SIGTERM.
while 1:
procv = session_proclist(
if len(procv) == 0:
for proc in procv:
emit('# leaked pid=%d %r %s' % (,, proc.cmdline()))
if !=
emit('# leaked pid=%d %r %s' % (,, proc.cmdline()))
gone, alive = psutil.wait_procs(procv, timeout=5)
for proc in alive:
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