Skip to content

[3.15] gh-156321: Don't eagerly log exceptions from a cancelled asyncio.shield() (GH-158590) - #158598

Merged
serhiy-storchaka merged 1 commit into
python:3.15from
miss-islington:backport-2095eab-3.15
Oct 10, 2026
Merged

serhiy-storchaka merged 1 commit into
python:3.15from
miss-islington:backport-2095eab-3.15

Conversation

@miss-islington

@miss-islington miss-islington commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

When the outer future returned by shield() was cancelled, a callback was
added to the inner future that reported its exception through the loop
exception handler as soon as it completed, even if the exception was
retrieved afterwards by awaiting the inner future or calling
exception(). Remove the callback; an exception nobody retrieves is
still reported by the inner future itself when it is garbage collected,
like any other future.
(cherry picked from commit 2095eab)

Co-authored-by: Kumar Aditya [email protected]

…o.shield() (pythonGH-158590)

When the outer future returned by shield() was cancelled, a callback was
added to the inner future that reported its exception through the loop
exception handler as soon as it completed, even if the exception was
retrieved afterwards by awaiting the inner future or calling
`exception()`. Remove the callback; an exception nobody retrieves is
still reported by the inner future itself when it is garbage collected,
like any other future.
(cherry picked from commit 2095eab)

Co-authored-by: Kumar Aditya <[email protected]>
@serhiy-storchaka
serhiy-storchaka merged commit 7c6432b into python:3.15 Oct 10, 2026
61 checks passed
@miss-islington
miss-islington deleted the backport-2095eab-3.15 branch October 10, 2026 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants