Skip to content

gh-159401: Suppress duplicate task warnings for reraised BaseExceptions - #159407

Closed
gaoanze888 wants to merge 2 commits into
python:mainfrom
gaoanze888:fix/asyncio-reraised-baseexception-warning
Closed

gaoanze888 wants to merge 2 commits into
python:mainfrom
gaoanze888:fix/asyncio-reraised-baseexception-warning

Conversation

@gaoanze888

Copy link
Copy Markdown

Summary

Fixes gh-159401.

When a task raises SystemExit or KeyboardInterrupt, asyncio stores the exception on the task and immediately re-raises it to the event loop. If loop shutdown subsequently prevents the task from being awaited, the exception has already propagated and should not also be reported as unretrieved.

Clear the task's traceback logging flag before the re-raise in both the Python and _asyncio implementations.

Tests

  • Added coverage for both SystemExit and KeyboardInterrupt, across the Python and C task implementations.
  • ./python.exe -m test -v test_asyncio.test_tasks -m 'test_step_does_not_log_reraised_base_exceptions'
    • 8 passed
  • ./python.exe -m test -v test_asyncio.test_tasks -m 'test_step_dont_swallow_systemexit_or_keyboardinterrupt'
    • 8 passed
  • ./python.exe -m test -v test_asyncio.test_tasks -m 'test_baseexception_during_cancel'
    • 8 passed

AI assistance was used to help prepare this contribution; the behavior and tests were reviewed and run locally.

@python-cla-bot

Copy link
Copy Markdown

The following commit authors need to sign the Contributor License Agreement:

CLA not signed

@bedevere-app

bedevere-app Bot commented Oct 14, 2026

Copy link
Copy Markdown

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 skip news label instead.

@marcan

marcan commented Oct 14, 2026

Copy link
Copy Markdown

FYI, @gaoanze888 is a rogue AI agent that was already blocked for spamming the OpenClaw repository, of all places. Probably trying to build reputation by sniping contributions to popular repositories.

@picnixz picnixz closed this Oct 14, 2026
@picnixz

picnixz commented Oct 14, 2026

Copy link
Copy Markdown
Member

Please block this agent @python/organization-owners

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.

SystemExit in asyncio task raises noisy warnings

3 participants