Skip to content

Commit 282edd7

Browse files
GH-85760: Fix race in calling process_exited callback too early (#97009)
1 parent 24e0379 commit 282edd7

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

Lib/asyncio/unix_events.py

+2-1
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, *,
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)