Skip to content

Commit 43d8860

Browse files
GH-85760: Fix race in calling process_exited callback too early (GH-97009)
(cherry picked from commit 282edd7) Co-authored-by: Kumar Aditya <[email protected]>
1 parent 646aa7e commit 43d8860

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

Lib/asyncio/unix_events.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ async def _make_subprocess_transport(self, protocol, args, shell,
223223
return transp
224224

225225
def _child_watcher_callback(self, pid, returncode, transp):
226-
self.call_soon_threadsafe(transp._process_exited, returncode)
226+
# Skip one iteration for callbacks to be executed
227+
self.call_soon_threadsafe(self.call_soon, transp._process_exited, returncode)
227228

228229
async def create_unix_connection(
229230
self, protocol_factory, path=None, *,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix race condition in :mod:`asyncio` where :meth:`~asyncio.SubprocessProtocol.process_exited` called before the :meth:`~asyncio.SubprocessProtocol.pipe_data_received` leading to inconsistent output. Patch by Kumar Aditya.

0 commit comments

Comments
 (0)