-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-124958: fix asyncio.TaskGroup and _PyFuture refcycles #124959
Conversation
graingert
commented
Oct 4, 2024
•
edited by bedevere-app
bot
Loading
edited by bedevere-app
bot
- Issue: refcycles in exceptions raised from asyncio.TaskGroup #124958
@@ -66,94 +66,103 @@ async def __aenter__(self): | |||
return self | |||
|
|||
async def __aexit__(self, et, exc, tb): | |||
self._exiting = True | |||
try: |
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 don't like this huge diff. Can you instead factor out the code of __aexit__
in a helper function (so that code keeps all of the existing indentation) and nest a call to it in try..finally in __aexit__
?
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.
It needs to delete locals as well as instance attributes so it's not possible
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 is. Instance attributes are not a problem at all. Locals are solvable too:
try:
raise propagate_cancellation_error
finally:
del propagate_cancellation_error
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 pushed the changes but it introduces a bunch of extra places to delete things, so I prefer the one big try/finally. You can also just view the diff with whitespace hidden: 1a4f2b5?w=1 which should look like this:
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.
lgtm, sorry for being a bit of a PITA with this review, but I think this version of the PR does read better by having most of the cleanup code more visible.
Thanks @graingert for the PR, and @1st1 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13. |
…nGH-124959) (cherry picked from commit d5dbbf4) Co-authored-by: Thomas Grainger <tagrain@gmail.com>
Thank you Thomas! |
Sorry, @graingert and @1st1, I could not cleanly backport this to
|
GH-125463 is a backport of this pull request to the 3.13 branch. |
@graingert Please submit a separate PR to 3.12, albeit I'm not sure we should port it to 3.12. |
GH-125466 is a backport of this pull request to the 3.12 branch. |
python#124959)" This reverts commit d5dbbf4.
…PyFuture refcycles (pythonGH-12… (pythonGH-125476) Revert "pythongh-124958: fix asyncio.TaskGroup and _PyFuture refcycles (pythonGH-124959)" This reverts commit d5dbbf4. (cherry picked from commit e99650b) Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>