Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terminate worker tasks on SIGINT #709

Merged
merged 1 commit into from
Jan 4, 2024

Conversation

nkaretnikov
Copy link
Contributor

@nkaretnikov nkaretnikov commented Dec 17, 2023

Fixes #707.

Description

This pull request: installs a signal handler that terminates worker tasks on Ctrl-C (SIGINT).

If the requested signal isn't supported on the current platform, the operation will be ignored.

Notes:

  • we cannot use celery control because it's broker-dependent, which wouldn't work with standalone
  • printing a worker pid and asking users to terminate that wouldn't work because celery beat would respawn
  • using install_worker_term_hard_handler wouldn't work because not all tasks would be terminated
  • using a signal handler is the only solution I've found given the above constraints, it's what install_worker_term_hard_handler uses internally as well.

Tested on Windows and Linux. All processes are terminated as expected.

Pull request checklist

  • Did you test this change locally?
  • Did you update the documentation (if required)?
  • Did you add/update relevant tests for this change (if required)?

Additional information

Copy link

netlify bot commented Dec 17, 2023

Deploy Preview for kaleidoscopic-dango-0cf31d canceled.

Name Link
🔨 Latest commit 0237f94
🔍 Latest deploy log https://app.netlify.com/sites/kaleidoscopic-dango-0cf31d/deploys/6596fe8bd78e4a0008c494a4

@trallard
Copy link
Collaborator

trallard commented Jan 4, 2024

@nkaretnikov there is a merge conflict - can you fix this and we can merge right away

@nkaretnikov nkaretnikov merged commit ec60664 into conda-incubator:main Jan 4, 2024
18 checks passed
@nkaretnikov nkaretnikov deleted the shutdown-worker-707 branch January 4, 2024 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done 💪🏾
Development

Successfully merging this pull request may close these issues.

Terminate worker subprocess in standalone mode
3 participants