Skip to content

gh-128552: fix refcycles in eager task creation - #128553

Merged
kumaraditya303 merged 13 commits into
python:mainfrom
graingert:fix-taskgroup-eager-refcycle
Jan 7, 2025
Merged

kumaraditya303 merged 13 commits into
python:mainfrom
graingert:fix-taskgroup-eager-refcycle

Conversation

@graingert

@graingert graingert commented Jan 6, 2025 •

Copy link
Copy Markdown
Contributor
Comment thread Lib/asyncio/base_events.py Resolved
Comment thread Lib/asyncio/taskgroups.py Resolved
@graingert
graingert marked this pull request as ready for review January 6, 2025 18:45
Comment thread Lib/asyncio/base_events.py Resolved
Comment thread Lib/asyncio/taskgroups.py Resolved
Comment thread Lib/asyncio/taskgroups.py Resolved
@kumaraditya303

Copy link
Copy Markdown
Contributor

if possible can you add a test which uses weakref to check for refcycle

Comment thread Lib/asyncio/base_events.py Resolved

from test.test_asyncio.utils import await_without_task

# To prevent a warning "test altered the execution environment"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this isn't needed as you have changed it to use asyncio.EventLoop but let's keep it for now, it is easy to make a mistake on altering policy and is a pain to fix in CI if it happens without this.

@kumaraditya303 kumaraditya303 self-assigned this Jan 7, 2025

self.assertIsNone(task_wr())
self.assertIsInstance(exc, _Done)
self.assertListEqual(gc.get_referrers(exc), no_other_refs())

@kumaraditya303 kumaraditya303 Jan 7, 2025 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was later changed that coro doesn't hold ref to locals, no_other_refs should not be necessary here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah its not merged yet #125640

@kumaraditya303 kumaraditya303 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@kumaraditya303
kumaraditya303 enabled auto-merge (squash) January 7, 2025 11:42
@kumaraditya303
kumaraditya303 merged commit 61b9811 into python:main Jan 7, 2025
@graingert graingert added the needs backport to 3.13 only security fixes label Jan 7, 2025
@miss-islington-app

Copy link
Copy Markdown

Thanks @graingert for the PR, and @kumaraditya303 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

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

cherry_picker 61b9811ac6843e22b5896ef96030d421b79cd892 3.13
@graingert graingert added the needs backport to 3.12 only security fixes label Jan 7, 2025
@miss-islington-app

Copy link
Copy Markdown

Thanks @graingert for the PR, and @kumaraditya303 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

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

cherry_picker 61b9811ac6843e22b5896ef96030d421b79cd892 3.12
@graingert
graingert deleted the fix-taskgroup-eager-refcycle branch January 7, 2025 11:46
@bedevere-app

bedevere-app Bot commented Jan 7, 2025

Copy link
Copy Markdown

GH-128585 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label Jan 7, 2025
graingert added a commit to graingert/cpython that referenced this pull request Jan 7, 2025
@bedevere-app

bedevere-app Bot commented Jan 7, 2025

Copy link
Copy Markdown

GH-128586 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.12 only security fixes label Jan 7, 2025
srinivasreddy pushed a commit to srinivasreddy/cpython that referenced this pull request Jan 8, 2025
kumaraditya303 pushed a commit that referenced this pull request Jan 8, 2025
…8585)

gh-128552: fix refcycles in eager task creation (#128553)

(cherry picked from commit 61b9811)
@bedevere-app

bedevere-app Bot commented Jan 20, 2025

Copy link
Copy Markdown

GH-128586 is a backport of this pull request to the 3.12 branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants