From f37d8776f923a3a7dfca80f00e7c0598c9cfa2f5 Mon Sep 17 00:00:00 2001 From: Brian Kubisiak Date: Thu, 24 Sep 2026 14:23:19 +0000 Subject: [PATCH] main: Fix ctrl-c being ignored at the upload confirmation prompt Installing a loop signal handler for sigint replaces python's default handler, so KeyboardInterrupt is never raised. Synchronous code running inside main, such as the input() in wait_for_confirmation, blocks until enter is pressed, after which the queued cancel fires at the next await and interrupts the upload partway through pushing. Keep the default handler instead, and cancel main once the KeyboardInterrupt reaches the top level so it still unwinds and cleans up rather than being abandoned suspended. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Brian Kubisiak --- revup/__main__.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/revup/__main__.py b/revup/__main__.py index 858fbaa..a9c68b7 100644 --- a/revup/__main__.py +++ b/revup/__main__.py @@ -1,7 +1,6 @@ # PYTHON_ARGCOMPLETE_OK import asyncio import logging -import signal import sys from revup.core_types import ( @@ -24,13 +23,14 @@ def _main() -> None: revup_parser, all_parsers = build_parser() loop = asyncio.new_event_loop() task = loop.create_task(main(revup_parser, all_parsers)) - # Let the loop cancel main on sigint, so it unwinds and cleans up instead of being - # abandoned suspended. Windows has no signal handling for loops. - if sys.platform != "win32": - loop.add_signal_handler(signal.SIGINT, task.cancel) try: sys.exit(loop.run_until_complete(task)) - except (asyncio.CancelledError, KeyboardInterrupt): + except KeyboardInterrupt: + task.cancel() + try: + loop.run_until_complete(task) + except (asyncio.CancelledError, KeyboardInterrupt): + pass # Exit code of 130 is the shell convention for death by sigint. logging.error("Interrupted") sys.exit(130)