[issue25942] Add a new optional cleanup_timeout parameter to subprocess.call()
Gregory P. Smith
report at bugs.python.org
Wed Dec 27 23:08:03 EST 2017
Gregory P. Smith <greg at krypto.org> added the comment:
you'll notice I added an alternate PR. I don't like the complication of adding yet another knob (cleanup_timeout) to subprocesses already giant API surface. It will rarely be used.
My PR tries to take a practical approach: Just wait a little while (arbitrary value of little chosen in the code) for the child after receiving SIGINT before reraising the exception and triggering a .kill() matching existing behavior.
The one controversial thing in my PR (which could be undone, it is independent of the other changes) is that I also modify the context manager __exit__ behavior to not do an infinite wait() upon KeyboardInterrupt. This means context managers of Popen _will_ complete potentially leaving a dangling process around (which our existing __del__ will pick up and put in the internal subprocess._active list). Relatively harmless, but a change none-the-less.
I went that far to try and better match the Python 2.7 and 3.2 behavior: On SIGINT our process sees the KeyboardInterrupt "right away" (not quite as instantaneously here given the wait timeouts, but close enough for interactive command line tool ^C happiness).
It seems like an improvement all around and is IMNSHO less complicated.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue25942>
_______________________________________
More information about the Python-bugs-list
mailing list