Taskiq version
0.12.4
Python version
Python 3.12
OS
Linux
What happened?
Description
The documentation describes --hardkill-count as the number of termination signals allowed before performing a hardkill.
However, the counter is currently implemented as:
hardkill_counter = 0
def interrupt_handler(signum, _frame):
nonlocal hardkill_counter
shutdown_event.set()
if hardkill_counter > args.hardkill_count:
logger.warning("Hard kill. Exiting.")
raise KeyboardInterrupt
hardkill_counter += 1
Because the comparison happens before incrementing and uses >, --hardkill-count 3 behaves as follows:
| Signal |
Counter before signal |
Result |
| 1 |
0 |
Graceful shutdown |
| 2 |
1 |
Graceful shutdown |
| 3 |
2 |
Graceful shutdown |
| 4 |
3 |
Graceful shutdown |
| 5 |
4 |
Hardkill |
If the value means “three termination signals before hardkill,” I would expect the fourth signal to trigger the hardkill. The current implementation triggers it on the fifth signal.
Would this condition be expected to use >= instead?
if hardkill_counter >= args.hardkill_count:
logger.warning("Hard kill. Exiting.")
raise KeyboardInterrupt
Taskiq version
0.12.4
Python version
Python 3.12
OS
Linux
What happened?
Description
The documentation describes
--hardkill-countas the number of termination signals allowed before performing a hardkill.However, the counter is currently implemented as:
Because the comparison happens before incrementing and uses
>,--hardkill-count 3behaves as follows:If the value means “three termination signals before hardkill,” I would expect the fourth signal to trigger the hardkill. The current implementation triggers it on the fifth signal.
Would this condition be expected to use
>=instead?