Skip to content

Make the SIGKILL timeout configurable with start --timeout - #258

Open
meysam-licenseware wants to merge 1 commit into
nickstenning:mainfrom
meysam-licenseware:start-timeout
Open

meysam-licenseware wants to merge 1 commit into
nickstenning:mainfrom
meysam-licenseware:start-timeout

Conversation

@meysam-licenseware

Copy link
Copy Markdown

Closes #189.

Honcho sends SIGKILL to the remaining processes 5 seconds after the first one exits (KILL_WAIT in honcho/manager.py). Processes that finish in-flight work when they get SIGTERM, such as a job queue worker completing its current job, are killed part-way through whenever that takes longer than 5 seconds, and there is no way to change it.

This adds Foreman's option for it. foreman start -t, --timeout is documented as "the amount of time (in seconds) processes have to shutdown gracefully before receiving a SIGKILL, defaults to 5".

Changes

  • Manager takes kill_wait (default KILL_WAIT, still 5), and loop() uses it. The module constant stays, so existing callers are unaffected.
  • honcho start -t N / --timeout N passes it through. The default is unchanged.
  • doc/using_procfiles.rst describes the shutdown sequence and the option; CHANGELOG.rst gets an Unreleased entry.

Tests

  • tests/test_manager.py: a clock that advances on every read, plus a process manager that records terminate/kill. They check that the straggler is killed only after the wait: after 5 s by default, and after 0 s and 10 s when configured.
  • tests/test_command.py: -t/--timeout parse, the default matches KILL_WAIT, and command_start passes the value to Manager.
  • tests/integration/test_start.py: a process needs 1 s to finish after SIGTERM. It finishes under the default and is killed with --timeout 0. Skipped on Windows.

Tests pass on every interpreter in the matrix on the fork: 142 passed on CPython 3.8–3.13 and PyPy 3.9/3.10, against 135 on unchanged main (branch run, main run).

The lint env fails in both runs with the same 17 RUF059 errors in existing tests (ret, out, err = ... with unused names). tox installs ruff unpinned, and the version it got here (0.16.8) reports that rule. This PR adds no new findings. I am happy to fix the existing ones in a separate PR, or to pin ruff, if you prefer.

🤖 Generated with Claude Code

Honcho sends SIGKILL to the remaining processes 5 seconds after the first
one exits. That cuts short processes which need longer to shut down
gracefully, such as a job queue worker finishing its current job (nickstenning#189).

Add a kill_wait argument to Manager and a -t/--timeout option to
`honcho start`, with the same name and meaning as Foreman's. The default
is still 5 seconds.

Closes nickstenning#189.

This branch has not been deployed

No deployments
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.

Preventing SIGKILL

1 participant