Skip to content

Commit d8276f8

Browse files
committed
Move waiter wakeup to later in _process_exited
This allows waiters to be scheduled after protocol.process_exited and/or connection_lost callbacks.
1 parent bc780d4 commit d8276f8

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

Lib/asyncio/base_subprocess.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -234,15 +234,6 @@ def _process_exited(self, returncode):
234234
logger.info('%r exited with return code %r', self, returncode)
235235
self._returncode = returncode
236236

237-
# gh-119710: Wake up futures waiting for wait() as soon as the process
238-
# exits. The pipe transports now check for the loop being closed before
239-
# scheduling a callback preventing gh-114177. This is consistent with
240-
# the behavior prior to 3.11 and the documented semantics in _wait().
241-
for waiter in self._exit_waiters:
242-
if not waiter.done():
243-
waiter.set_result(returncode)
244-
self._exit_waiters = None
245-
246237
if self._proc.returncode is None:
247238
# asyncio uses a child watcher: copy the status into the Popen
248239
# object. On Python 3.6, it is required to avoid a ResourceWarning.
@@ -251,6 +242,13 @@ def _process_exited(self, returncode):
251242

252243
self._try_finish()
253244

245+
# gh-119710: Wake up futures waiting for wait() as soon as the process
246+
# exits.
247+
for waiter in self._exit_waiters:
248+
if not waiter.done():
249+
waiter.set_result(returncode)
250+
self._exit_waiters = None
251+
254252
async def _wait(self):
255253
"""Wait until the process exit and return the process return code.
256254

0 commit comments

Comments
 (0)