GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-128552: fix refcycles in eager task creation by graingert · Pull Request #128553 · python/cpython

Conversation

@graingert

@graingert graingert commented Jan 6, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor
  • Issue: TaskGroup's task's exception's participate in a reference cycle, via TaskGroup.create_task -> task -> exception and loop.create_task -> task -> exception #128552

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@graingert
pythongh-128552: fix refcycles in eager task creation
c82f30b
@bedevere-app bedevere-app Bot mentioned this pull request Jan 6, 2025
TaskGroup's task's exception's participate in a reference cycle, via TaskGroup.create_task -> task -> exception and loop.create_task -> task -> exception #128552
Closed
graingert
graingert commented Jan 6, 2025
View reviewed changes
Comment thread Lib/asyncio/base_events.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@graingert
Update Lib/asyncio/base_events.py
8a4eb56
graingert
graingert commented Jan 6, 2025
View reviewed changes
Comment thread Lib/asyncio/taskgroups.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@graingert
Update Lib/asyncio/taskgroups.py
35a38e4
@graingert graingert mentioned this pull request Jan 6, 2025
gh-128550: TaskGroup: cancel tasks added to set after aborting #128551
Closed
blurb-it Bot and others added 2 commits January 6, 2025 18:41
@blurb-it
📜🤖 Added by blurb_it.
afd3053
@graingert
Rename 2025-01-06-18-41-08.gh-issue-pythongh-128552.fV-f8j.rst to 202…
9700ebf
…5-01-06-18-41-08.gh-issue-128552.fV-f8j.rst
@graingert
graingert marked this pull request as ready for review January 6, 2025 18:45
@graingert
graingert requested review from 1st1, asvetlov, kumaraditya303 and willingc as code owners January 6, 2025 18:45
@bedevere-app bedevere-app Bot added the awaiting review label Jan 6, 2025
graingert
graingert commented Jan 6, 2025
View reviewed changes
Comment thread Misc/NEWS.d/next/Library/2025-01-06-18-41-08.gh-issue-128552.fV-f8j.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@graingert
Update Misc/NEWS.d/next/Library/2025-01-06-18-41-08.gh-issue-128552.f…
fe83add
…V-f8j.rst
@graingert
graingert requested a review from ZeroIntensity January 6, 2025 19:01
@graingert
Merge branch 'main' into fix-taskgroup-eager-refcycle
a1f76df
ZeroIntensity
ZeroIntensity reviewed Jan 6, 2025
View reviewed changes
Comment thread Lib/asyncio/base_events.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/asyncio/taskgroups.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/asyncio/taskgroups.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@ZeroIntensity ZeroIntensity added the topic-asyncio label Jan 6, 2025
@kumaraditya303

kumaraditya303 commented Jan 7, 2025

Copy link
Copy Markdown
Contributor

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

graingert added 3 commits January 7, 2025 08:06
@graingert
add a version of the test with weakrefs
7c966d0
@graingert
Merge branch 'main' into fix-taskgroup-eager-refcycle
89362f5
@graingert
simplify and comment
cf5cfe3
graingert
graingert commented Jan 7, 2025
View reviewed changes
Comment thread Lib/asyncio/base_events.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@graingert
Update Lib/asyncio/base_events.py
18b6ea9
@graingert
graingert requested a review from ZeroIntensity January 7, 2025 09:01
kumaraditya303
kumaraditya303 reviewed Jan 7, 2025
View reviewed changes
Comment thread Lib/test/test_asyncio/test_taskgroups.py

from test.test_asyncio.utils import await_without_task

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

@kumaraditya303 kumaraditya303 Jan 7, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
graingert
graingert commented Jan 7, 2025
View reviewed changes
Comment thread Lib/test/test_asyncio/test_taskgroups.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@graingert
restore _set_event_loop_policy(None)
ca71935
graingert
graingert commented Jan 7, 2025
View reviewed changes
Comment thread Lib/test/test_asyncio/test_taskgroups.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@graingert
remove type annotations
cc39717
@kumaraditya303 kumaraditya303 self-assigned this Jan 7, 2025
kumaraditya303
kumaraditya303 reviewed Jan 7, 2025
View reviewed changes
Comment thread Lib/test/test_asyncio/test_taskgroups.py

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

@kumaraditya303 kumaraditya303 Jan 7, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@kumaraditya303 kumaraditya303 Jan 7, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
kumaraditya303
kumaraditya303 approved these changes Jan 7, 2025
View reviewed changes

@kumaraditya303 kumaraditya303 left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

miss-islington-app Bot commented Jan 7, 2025

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.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington-app

miss-islington-app Bot commented Jan 7, 2025

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
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

miss-islington-app Bot commented Jan 7, 2025

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.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington-app

miss-islington-app Bot commented Jan 7, 2025

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
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@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
@graingert
pythongh-128552: fix refcycles in eager task creation (python#128553)
ceaafff
(cherry picked from commit 61b9811)
@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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@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
@graingert @srinivasreddy
pythongh-128552: fix refcycles in eager task creation (python#128553)
c50dfd7
kumaraditya303 pushed a commit that referenced this pull request Jan 8, 2025
@graingert
[3.13] gh-128552: fix refcycles in eager task creation (#128553) (#12…
1383588
…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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@belm0 belm0 mentioned this pull request Apr 23, 2026
gh-108951: add TaskGroup.cancel() #127214
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@kumaraditya303 kumaraditya303 kumaraditya303 approved these changes
@1st1 1st1 Awaiting requested review from 1st1 1st1 is a code owner
@asvetlov asvetlov Awaiting requested review from asvetlov asvetlov is a code owner
@willingc willingc Awaiting requested review from willingc willingc is a code owner
@ZeroIntensity ZeroIntensity Awaiting requested review from ZeroIntensity

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@kumaraditya303 kumaraditya303

Labels

topic-asyncio

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@graingert @kumaraditya303 @ZeroIntensity
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.