Gregory P. Smith <g...@krypto.org> added the comment:
even with that initially proposed patch, the subprocess.run code is going to hang if the .kill() fails without raising an exception: The run() TimeoutExpired path calls communicate() after the kill to consume all remaining output: https://github.com/python/cpython/blob/master/Lib/subprocess.py#L478 and the __exit__ code path calls wait(). both assume that the kill() succeeded because the normal case is not someone launching a child process that they are unable to kill (as happens when sudo or similar is used). Today's workarounds: Don't use timeout when launching a child you cannot kill. OR launch it via an intermediate process that you can kill (shell=True or equivalent). To address this issue, catching a PermissionError exception around both of those kill() calls and preventing it from calling either communicate() or wait() as we cannot force the child process to exit makes sense. With some indication that this happened left as a hint to the user on the TimeoutExpired itself. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue37091> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com