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 dontbugme
Recipients asvetlov, dontbugme, yselivanov
Date 2019-12-06.17:41:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1575654060.86.0.979877919031.issue38988@roundup.psfhosted.org>
In-reply-to
Content
I'm trying to use asyncio.subproceess and am having difficulty killing the subprocesses after timeout. My use case is launching processes that hold on to file handles and other exclusive resources, so subsequent processes can only be launched after the first ones are fully stopped.


The documentation on https://docs.python.org/3/library/asyncio-subprocess.html#asyncio.asyncio.subprocess.Process say there is no timeout-parameter and suggests using wait_for() instead.
I tried this but it's kind of a footgun because the wait_for() times out but the process still lives on in the background. See Fail(1) and Fail(2) in attached test1().


To solve this i tried to catch the CancelledError and in the exception handler kill the process myself. While this worked it's also semi dangerous because it takes some time for the process to get killed and the wait() after kill() runs in the background as some kind of detached task. See Fail(3) in attached test2().
This i can sortof understand because after TimeoutError something would have to block for wait() to actually finish and this is impossible.

After writing this i feel myself there is no good solution for Fail#3 because again, timeouts can't be blocking. Maybe some warning in the documentation would be appropriate for Fail(1+2) because the suggestion in the documentation right now is quite misleading, the wait_for()-alternative to timeout-parameter does not behave like the timeout-parameter in ordinary subprocess.Popen.wait()
History
Date User Action Args
2019-12-06 17:41:00dontbugmesetrecipients: + dontbugme, asvetlov, yselivanov
2019-12-06 17:41:00dontbugmesetmessageid: <1575654060.86.0.979877919031.issue38988@roundup.psfhosted.org>
2019-12-06 17:41:00dontbugmelinkissue38988 messages
2019-12-06 17:41:00dontbugmecreate