Skip to content

Commit bd97ffd

Browse files
committed
gh-146194: Fix nested KeyboardInterrupt handling in asyncio
- Modify _on_sigint to cancel main task on every SIGINT - Allow nested cancellations to propagate correctly through multiple levels - Add test_nested_keyboardinterrupt_handling to test_runners.py - Add NEWS entry Fixes issue where third Ctrl+C would crash with: 'Task was destroyed but it is pending!'
1 parent 2976259 commit bd97ffd

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

Misc/NEWS.d/next/Library/2026-03-20-04-20-47.gh-issue-146194.aXjDnd.rst

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.. gh-issue: 146194
2+
3+
.. section: Library
4+
5+
Fix nested :exc:`KeyboardInterrupt` handling in :mod:`asyncio`.
6+
Previously, multiple Ctrl+C presses would cause a crash with
7+
``Task was destroyed but it is pending!``. Now nested cancellations
8+
propagate correctly through multiple levels.

0 commit comments

Comments
 (0)