Uh oh!
There was an error while loading. Please reload this page.
gh-119710: Let asyncio Process.wait() finish on only process exit. - #151983
Conversation
e774576 to
f6df3f5CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Letting Process.wait() only wait on actual process return is closer to how it's documented and consistent with Popen.wait(). This also reduces complexity for waking waiters which was inconsistend depending on ordering of wait/exit.
f6df3f5 to
e703a76CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This allows waiters to be scheduled after protocol.process_exited and/or connection_lost callbacks.
I simplified the added test and also fixed it, now it correctly fails on main branch but passes on this. here's the failure on windows: ======================================================================ERROR: test_wait_even_if_pipe_is_open (test.test_asyncio.test_subprocess.SubprocessProactorTests.test_wait_even_if_pipe_is_open)----------------------------------------------------------------------Traceback (most recent call last): File "D:\cpython\Lib\asyncio\tasks.py", line 488, in wait_for return await fut ^^^^^^^^^ File "D:\cpython\Lib\asyncio\subprocess.py", line 137, in wait return await self._transport._wait() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\cpython\Lib\asyncio\base_subprocess.py", line 255, in _wait return await waiter ^^^^^^^^^^^^asyncio.exceptions.CancelledErrorThe above exception was the direct cause of the following exception:Traceback (most recent call last): File "D:\cpython\Lib\test\test_asyncio\test_subprocess.py", line 446, in test_wait_even_if_pipe_is_open self.loop.run_until_complete(run()) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^ File "D:\cpython\Lib\asyncio\base_events.py", line 725, in run_until_complete return future.result() ~~~~~~~~~~~~~^^ File "D:\cpython\Lib\test\test_asyncio\test_subprocess.py", line 436, in run returncode = await asyncio.wait_for( ^^^^^^^^^^^^^^^^^^^^^^^ wait_proc, timeout=support.SHORT_TIMEOUT) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\cpython\Lib\asyncio\tasks.py", line 487, in wait_for async with timeouts.timeout(timeout): ~~~~~~~~~~~~~~~~^^^^^^^^^ File "D:\cpython\Lib\asyncio\timeouts.py", line 115, in __aexit__ raise TimeoutError from exc_valTimeoutError----------------------------------------------------------------------Ran 41 tests in 35.871s |
Uh oh!
There was an error while loading. Please reload this page.
Thanks @tapetersen for the PR, and @kumaraditya303 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15. |
GH-154170 is a backport of this pull request to the 3.15 branch. |
GH-154171 is a backport of this pull request to the 3.14 branch. |
GH-154172 is a backport of this pull request to the 3.13 branch. |
tapetersen
commented
Jul 19, 2026
@kumaraditya303 Thanks for the review and windows fix. |
… and not wait for closing of pipes (pythonGH-151983) (cherry picked from commit f252132) Co-authored-by: Tobias Alex-Petersen <tobias.alex.petersen@gmail.com> Co-authored-by: Kumar Aditya <kumaraditya@python.org>
…t and not wait for closing of pipes (GH-151983) (#154172) gh-119710: fix asyncio Process.wait() to finish on process exit and not wait for closing of pipes (GH-151983) (cherry picked from commit f252132) Co-authored-by: Tobias Alex-Petersen <tobias.alex.petersen@gmail.com> Co-authored-by: Kumar Aditya <kumaraditya@python.org>
…t and not wait for closing of pipes (GH-151983) (#154171) gh-119710: fix asyncio Process.wait() to finish on process exit and not wait for closing of pipes (GH-151983) (cherry picked from commit f252132) Co-authored-by: Tobias Alex-Petersen <tobias.alex.petersen@gmail.com> Co-authored-by: Kumar Aditya <kumaraditya@python.org>
…t and not wait for closing of pipes (GH-151983) (#154170) * gh-119710: fix asyncio Process.wait() to finish on process exit and not wait for closing of pipes (GH-151983) (cherry picked from commit f252132) Co-authored-by: Tobias Alex-Petersen <tobias.alex.petersen@gmail.com> Co-authored-by: Kumar Aditya <kumaraditya@python.org>
gh-119710: Let asyncio Process.wait() finish on only process exit
Letting Process.wait() only wait on actual process return is closer to how it's documented and consistent with Popen.wait(). This also reduces complexity for waking waiters which was inconsistend depending on ordering of wait/exit.