Skip to content

--hardkill-count appears off by one #647

Description

@aysanorhun

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=0definterrupt_handler(signum, _frame):
nonlocalhardkill_countershutdown_event.set()
ifhardkill_counter>args.hardkill_count:
logger.warning("Hard kill. Exiting.")
raiseKeyboardInterrupthardkill_counter+=1

Because the comparison happens before incrementing and uses >, --hardkill-count 3 behaves as follows:

SignalCounter before signalResult
10Graceful shutdown
21Graceful shutdown
32Graceful shutdown
43Graceful shutdown
54Hardkill

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?

ifhardkill_counter>=args.hardkill_count:
logger.warning("Hard kill. Exiting.")
raiseKeyboardInterrupt

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions