[New-bugs-announce] [issue31387] asyncio should make it easy to enable cooperative SIGINT handling

Nick Coghlan report at bugs.python.org
Thu Sep 7 15:37:30 EDT 2017

New submission from Nick Coghlan:

Issue 29988 covers the fact that with the default SIGINT handler installed, a poorly timed Ctrl-C can lead to context managers failing to even start running their __(a)exit__ methods, let alone complete them.

For the asynchronous case, the problem is even worse, as the *event loop* may be interrupted at arbitrary points if the default SIGINT handler is left in place.

To handle this robustly, it's desirable to make it easy to switch event-driven programs over to cooperative Ctrl-C handling by installing an asyncio SIGINT handler while the event loop is running, rather than leaving the default SIGINT handler in place.

(Note: while installing a cooperative SIGINT handler will enable more robust event-loop managed resource cleanup, it will have the downside that Ctrl-C won't be able to interrupt a coroutine that has incorrectly blocked the main thread)

components: Library (Lib)
messages: 301619
nosy: giampaolo.rodola, gregory.p.smith, haypo, ncoghlan, njs, yselivanov
priority: normal
severity: normal
stage: needs patch
status: open
title: asyncio should make it easy to enable cooperative SIGINT handling
type: behavior
versions: Python 3.7

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list