classification
Title: asyncio should handle keyboard interrupt while the event loop is running
Type: behavior Stage:
Components: asyncio Versions: Python 3.10
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: asvetlov, gvanrossum, njs, paul.moore, scaramanga, yselivanov
Priority: normal Keywords:

Created on 2020-12-19 11:26 by paul.moore, last changed 2021-02-08 13:10 by scaramanga.

Messages (1)
msg383370 - (view) Author: Paul Moore (paul.moore) * (Python committer) Date: 2020-12-19 11:26
See the comment on Discourse here: https://discuss.python.org/t/feeding-data-generated-via-asyncio-into-a-synchronous-main-loop/5436/28 (and the thread leading up to this comment).

In the thread, @njs states that if the user hits Ctrl-C while the asyncio event loop is running, it's possible for internal asyncio data structures to end up in an inconsistent state. If that's the case, then this would make asyncio-based code unreliable in real-world use.

I don't have a way to reproduce this - from the Discourse thread, I had assumed that ctrl-C was safe to use on an asyncio-based program, but was told otherwise, and I can't find anything definitive either way.

At a minimum, the asyncio documentation should confirm that it is exception-safe (specifically against Ctrl-C, but in general I'd assume that asyncio is safe in the face of uncaught exceptions in user-written async code).
History
Date User Action Args
2021-02-08 13:10:38scaramangasetnosy: + scaramanga
2020-12-19 16:57:49gvanrossumsetnosy: + gvanrossum
2020-12-19 11:27:02paul.mooresetnosy: + njs
2020-12-19 11:26:28paul.moorecreate