From f85b19ec4523218116eedc5a235b79acb83899ff Mon Sep 17 00:00:00 2001 From: Jonathan Slenders Date: Thu, 27 Jan 2022 18:29:21 +0100 Subject: [PATCH] Don't attempt to handle SIGINT on Windows. --- prompt_toolkit/application/application.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/prompt_toolkit/application/application.py b/prompt_toolkit/application/application.py index 083c189f4..aec0accae 100644 --- a/prompt_toolkit/application/application.py +++ b/prompt_toolkit/application/application.py @@ -88,6 +88,7 @@ ) from prompt_toolkit.utils import Event, in_main_thread +from ..utils import is_windows from .current import get_app_session, set_app from .run_in_terminal import in_terminal, run_in_terminal @@ -659,8 +660,11 @@ async def run_async( """ assert not self._is_running, "Application is already running." - if not in_main_thread(): + if not in_main_thread() or is_windows(): # Handling signals in other threads is not supported. + # Also on Windows, `add_signal_handler(signal.SIGINT, ...)` raises + # `NotImplementedError`. + # See: https://github.com/prompt-toolkit/python-prompt-toolkit/issues/1553 handle_sigint = False async def _run_async() -> _AppResult: