Skip to content

Cancel queued up work on ctrl-c #425#433

Merged
gkreitz merged 1 commit into
Kattis:masterfrom
gkreitz:425_clean_shutdown_in_multithreading
Jun 17, 2026
Merged

Cancel queued up work on ctrl-c #425#433
gkreitz merged 1 commit into
Kattis:masterfrom
gkreitz:425_clean_shutdown_in_multithreading

Conversation

@gkreitz

@gkreitz gkreitz commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Improve the behavior of ctrl-c when running verifyproblem multithreaded. Now, if we're exiting due to a KeyboardInterrupt, we cancel all queued up futures, preventing new jobs from starting.

There is a potential for a race still if a thread starts a new run before we cancel (all running processes will get a SIGINT from the ctrl-c, so running jobs will die). I was completely unable to hit that race, so I kept my PR as simple as possible (Fixing it properly is painful. I originally had a heuristic which did a SIGTERM to all child processes, but removed it to simplify the PR when I saw that it seemed reliable enough without it).

Fixes #425

@gkreitz gkreitz merged commit 8c115d5 into Kattis:master Jun 17, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spam less when pressing ctrl+c

2 participants