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)