mirror of
https://github.com/NCBM/plyngent.git
synced 2026-11-07 15:37:55 +08:00
1973ef93bb
asyncio.run (Runner) replaces SIGINT with its own handler when the current one is signal.default_int_handler: the first Ctrl+C silently cancels the main task (invisible at the REPL prompt, leaving the task marked cancelled) and the second raises KeyboardInterrupt, so a Ctrl+D exit after a cancel was cancelled mid-memory.close() (SQLAlchemy CancelledError traceback) and the CLI died with "Aborted!". Install a distinct KeyboardInterrupt-raising handler before asyncio.run so Runner leaves SIGINT alone, and have run_cancellable restore the previous handler after each turn (remove_signal_handler leaves SIG_DFL, which would kill the process on a stray Ctrl+C between turns).