Skip to content

gh-139894: fix incorrect sharing of current task while forking in asyncio #139897

Merged
kumaraditya303 merged 2 commits into
python:mainfrom
kumaraditya303:asyncio-fork
Oct 10, 2025
Merged

gh-139894: fix incorrect sharing of current task while forking in asyncio #139897
kumaraditya303 merged 2 commits into
python:mainfrom
kumaraditya303:asyncio-fork

Conversation

@kumaraditya303

@kumaraditya303 kumaraditya303 commented Oct 10, 2025

Copy link
Copy Markdown
Contributor

Fix incorrect sharing of current task with the forked child process by clearing thread state's current task and current loop in PyOS_AfterFork_Child.

@kumaraditya303 kumaraditya303 added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Oct 10, 2025
@bedevere-bot

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @kumaraditya303 for commit 42f5468 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F139897%2Fmerge

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Oct 10, 2025
@kumaraditya303 kumaraditya303 merged commit b881df4 into python:main Oct 10, 2025
111 of 112 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @kumaraditya303 for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@kumaraditya303 kumaraditya303 deleted the asyncio-fork branch October 10, 2025 16:28
@miss-islington-app

Copy link
Copy Markdown

Sorry, @kumaraditya303, I could not cleanly backport this to 3.14 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker b881df47ff1adca515d1de04f689160ddae72142 3.14

kumaraditya303 added a commit to kumaraditya303/cpython that referenced this pull request Oct 10, 2025
…orking in `asyncio` (pythonGH-139897)

Fix incorrect sharing of current task with the forked child process by clearing thread state's current task and current loop in `PyOS_AfterFork_Child`.
(cherry picked from commit b881df4)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
@bedevere-app

bedevere-app Bot commented Oct 10, 2025

Copy link
Copy Markdown

GH-139913 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Oct 10, 2025
kumaraditya303 added a commit to kumaraditya303/cpython that referenced this pull request Oct 10, 2025
…orking in `asyncio` (pythonGH-139897)

Fix incorrect sharing of current task with the forked child process by clearing thread state's current task and current loop in `PyOS_AfterFork_Child`.
(cherry picked from commit b881df4)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
kumaraditya303 added a commit that referenced this pull request Oct 10, 2025
… in `asyncio` (GH-139897) (#139913)

* [3.14] gh-139894: fix incorrect sharing of current task while forking in `asyncio`  (GH-139897)

Fix incorrect sharing of current task with the forked child process by clearing thread state's current task and current loop in `PyOS_AfterFork_Child`.
(cherry picked from commit b881df4)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>

* Update Lib/test/test_asyncio/test_unix_events.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic-asyncio type-bug An unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants