-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-86802: Fix asyncio memory leak; shielded tasks where cancelled log… #134331
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
Conversation
…ed log once through the exception handler
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
@@ -972,10 +983,16 @@ def _inner_done_callback(inner, cur_task=cur_task): | |||
else: | |||
outer.set_result(inner.result()) | |||
|
|||
|
|||
def _outer_done_callback(outer): | |||
if not inner.done(): | |||
inner.remove_done_callback(_inner_done_callback) |
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.
Before this PR, this line made the future_discard_from_awaited_by
never execute for cases when the outer shield was cancelled. That was a memory leak, which is now fixed.
if cur_task is not None: | ||
inner.add_done_callback(_clear_awaited_by_callback) |
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.
Now we're only adding the callback to future_discard_from_awaited_by
when there is a current task. Nice.
Thanks @ChristianHrs for the PR, and @ambv for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14. |
… once through the exception handler (pythongh-134331) (cherry picked from commit f695eca) Co-authored-by: Christian Harries <[email protected]> Co-authored-by: Łukasz Langa <[email protected]>
GH-134343 is a backport of this pull request to the 3.14 branch. |
@ambv you are indeed a provider |
…g once through the exception handler (gh-134331) (gh-134343) (cherry picked from commit f695eca) Co-authored-by: Christian Harries <[email protected]> Co-authored-by: Łukasz Langa <[email protected]>
…ions log once through the exception handler (pythongh-134331)" This reverts commit f695eca.
…ions log once through the exception handler (pythongh-134331)" This reverts commit f695eca.
… once through the exception handler