This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author gregory.p.smith
Recipients gregory.p.smith, wesinator
Date 2019-06-08.18:47:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1560019669.75.0.612245129359.issue37091@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2019-06-08 18:47:49gregory.p.smithsetrecipients: + gregory.p.smith, wesinator
2019-06-08 18:47:49gregory.p.smithsetmessageid: <1560019669.75.0.612245129359.issue37091@roundup.psfhosted.org>
2019-06-08 18:47:49gregory.p.smithlinkissue37091 messages
2019-06-08 18:47:49gregory.p.smithcreate