summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-09-22 17:23:48 (GMT)
committerGitHub <noreply@github.com>2022-09-22 17:23:48 (GMT)
commit43d8860aa247148b95e654775acb10b2f7e7b571 (patch)
tree1431cc3e7e5a4a6e2a2cfcc9afe8c7ef569470a9
parent646aa7efb3a069150614049d43b469c2c9b4a965 (diff)
downloadcpython-43d8860aa247148b95e654775acb10b2f7e7b571.zip
cpython-43d8860aa247148b95e654775acb10b2f7e7b571.tar.gz
cpython-43d8860aa247148b95e654775acb10b2f7e7b571.tar.bz2
GH-85760: Fix race in calling process_exited callback too early (GH-97009)
(cherry picked from commit 282edd7b2a74c4dfe1bfe3c5b1d30f9c21d554d6) Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
-rw-r--r--Lib/asyncio/unix_events.py3
-rw-r--r--Misc/NEWS.d/next/Library/2022-09-22-11-50-29.gh-issue-85760.DETTPd.rst1
2 files changed, 3 insertions, 1 deletions
diff --git a/Lib/asyncio/unix_events.py b/Lib/asyncio/unix_events.py
index c88b818..39b5e83 100644
--- a/Lib/asyncio/unix_events.py
+++ b/Lib/asyncio/unix_events.py
@@ -223,7 +223,8 @@ class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop):
return transp
def _child_watcher_callback(self, pid, returncode, transp):
- self.call_soon_threadsafe(transp._process_exited, returncode)
+ # Skip one iteration for callbacks to be executed
+ self.call_soon_threadsafe(self.call_soon, transp._process_exited, returncode)
async def create_unix_connection(
self, protocol_factory, path=None, *,
diff --git a/Misc/NEWS.d/next/Library/2022-09-22-11-50-29.gh-issue-85760.DETTPd.rst b/Misc/NEWS.d/next/Library/2022-09-22-11-50-29.gh-issue-85760.DETTPd.rst
new file mode 100644
index 0000000..af8ae20
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2022-09-22-11-50-29.gh-issue-85760.DETTPd.rst
@@ -0,0 +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.