[issue37424] subprocess.run timeout does not function if shell=True and capture_output=True

Martin Panter report at bugs.python.org
Thu Jun 27 04:37:07 EDT 2019


Martin Panter <vadmium+py at gmail.com> added the comment:

Same thing going on as in Issue 30154. The shell is probably spawning the “sleep” command as a child process (grandchild of Python), and waiting for it to exit. When Python times out, it will kill the shell process, leaving the grandchild as an orphan. The “sleep” process will still be running and probably holds the “stdout” and/or “stderr” pipes open, and Python will wait indefinitely to be sure it has captured all the output to those pipes.

Also see Issue 26534 proposes APIs to kill a process group rather than the single child process.

----------
nosy: +martin.panter
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> subprocess.run with stderr connected to a pipe won't timeout when killing a never-ending shell commanad

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37424>
_______________________________________


More information about the Python-bugs-list mailing list