fix(cli): correct --hardkill-count off-by-one in worker signal handler#648
Open
gitcommit90 wants to merge 1 commit into
Open
fix(cli): correct --hardkill-count off-by-one in worker signal handler#648gitcommit90 wants to merge 1 commit into
gitcommit90 wants to merge 1 commit into
Conversation
The worker's interrupt handler compared hardkill_counter to args.hardkill_count with '>' before incrementing, so N allowed termination signals actually required N+2 signals to hard-kill (e.g. the default --hardkill-count 3 hard-killed on the 5th signal). Use '>=' so signal N+1 performs the hard kill, matching the CLI help text: 'Number of termination signals to the main process before performing a hardkill.' Add an integration test that spawns a real worker with a broker whose graceful shutdown hangs, sends SIGINTs to the worker child process, and asserts the worker survives N signals and is hard-killed on signal N+1. The test fails on the previous comparison and passes with this fix. Fixes taskiq-python#647
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #647:
--hardkill-count Nwas off by one in the worker signal handler.Docs/CLI help describe N as the number of termination signals allowed before a hard kill (hard kill on signal N+1). The handler compared
hardkill_counter > args.hardkill_countbefore incrementing, so with the defaultN=3the hard kill fired on the 5th signal instead of the 4th.Changes
taskiq/cli/worker/run.py: change>to>=so hard kill runs on signal N+1.tests/cli/worker/hanging_broker.pyandtests/cli/worker/test_hardkill_count.py— integration test that spawns a real worker with a broker whose graceful shutdown hangs, sends SIGINTs to the worker child, and asserts survival through N signals and hard kill on N+1.Test plan
pytest tests/ -q -n auto→ 298 passedruff check,ruff format --check,black --check,mypyclean on touched filesCloses #647