Skip to content

gh-108549: In asyncio, do not cancel the current task in Task.__step when a SystemExit exception was just raised - #156309

Open
YvesDup wants to merge 1 commit into
python:mainfrom
YvesDup:asyncio.gather-dont-raise-systemexit
Open

gh-108549: In asyncio, do not cancel the current task in Task.__step when a SystemExit exception was just raised #156309
YvesDup wants to merge 1 commit into
python:mainfrom
YvesDup:asyncio.gather-dont-raise-systemexit

Conversation

@YvesDup

@YvesDup YvesDup commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Modify the asyncio.Task.__step method to prevent a new CancelledErrorto be set when the current task must be cancelled and aSystemExitor a KeybordInterrupt exception is just raised.

The fix should also be pplied in the _asyncio module.

- Update `Task.__step`
,
- Update `_asyncio` module on the corresponding function,
- Add a `test_step_dont_swallow_systemexit`  test in  `test_task.py` file.
@kumaraditya303

Copy link
Copy Markdown
Contributor

This needs a news entry and added comments should be on a single line each if they are short.

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.

2 participants