Skip to content

Decide Whether the Python Interrupt Rule Routes SIGINT Through the SIGTERM Handler and Passes Over a Later Signal #4146

Closed

Description

@ptr727

Question

Should CODESTYLE.md "Interrupts in Python" (and the python-codestyle copy it generates) state that the entry point routes SIGINT through the same handler as SIGTERM, and that the handler passes over any signal after the first?

Background

The section today describes one handler, for SIGTERM. Python's own KeyboardInterrupt carries SIGINT.

Since #4145, .github/actions/prose-gate/prose_lint.py and catalog/snippets/hub_fetch_run.py install one handler for both signals, and that handler passes over any signal after the first, returning without raising. This closes a race. A Ctrl-C reaches the whole process group, and uv run then forwards a SIGTERM to the script it launched. Under the rule as written, that SIGTERM can land while the script is already cleaning up after the SIGINT, and interrupt the cleanup itself.

Writing this into the section is a new requirement for every fleet Python script, rather than a description of an existing one. The two other hub scripts that install a signal handler, scripts/docker_lint.py and host-setup/agent-safety/global_rules.py, install only the SIGTERM handler the section describes. That is why this is a question, and why the backlog-burndown run that found it did not change the rule.

host-setup/agent-safety/global_rules.py still has the race. That file is under host-setup/agent-safety/, so any change to it waits for the maintainer's approval whichever option is chosen.

Options

  1. Recommended: make it the rule for every Python script. The entry point installs one handler for SIGINT and SIGTERM that records the first signal and raises KeyboardInterrupt, and passes over any later one. Reason: uv run is the fleet's standard launcher, so the race reaches every script it launches. A carried rule that describes only the SIGTERM handler hands the race to the next script written from it. The python-codestyle description is at its 1024-character cap, but the change goes in the generated include body, so the description need not grow. Scripts that do not yet follow it, scripts/docker_lint.py and global_rules.py included, become follow-up work.
  2. Allow it as a permitted variant without requiring it. The section names the combined handler as acceptable, so a reviewer does not flag the two scripts, and leaves the single SIGTERM handler as the default. The race stays wherever a script does not opt in.
  3. Leave the rule as it is. The two scripts keep a stricter local pattern that the rule neither states nor forbids.

Filed by the backlog-burndown planner (away mode, round 3) for an unfiled disagreement that the #4145 merge left behind.

Activity

  1. added
    decision
    on Nov 13, 2026
  2. ptr727 commented on Nov 16, 2026

    @ptr727
    OwnerAuthor

    Answered by the maintainer, 2026-11-15: option 1, make it the rule. CODESTYLE.md "Interrupts in Python" requires every script's entry point to install one handler for SIGINT and SIGTERM. The handler records the first signal, raises KeyboardInterrupt, and passes over any later one. Bringing scripts/docker_lint.py and host-setup/agent-safety/global_rules.py into line is follow-up work. The global_rules.py change waits for the maintainer's diff read. This is now work.

  3. removed
    decision
    on Nov 16, 2026
  4. ptr727 commented on Nov 20, 2026

    @ptr727
    OwnerAuthor

    Decision triage (2026-11-19) found the open question here already answered, so it is not asked:

    The maintainer's 2026-11-16 answer (option 1) approves the design of the host-setup/agent-safety/global_rules.py signal-handler change. Only the merge of that edit waits on his diff read. Neither CODESTYLE.md "Interrupts in Python" nor global_rules.py has changed on main yet, so this is ordinary work for an attended run. #4100 is a related open question that edits the same bullets, so its answer should land in the same pull request.

  5. ptr727 commented on Nov 20, 2026

    @ptr727
    OwnerAuthor

    Backlog burndown claim (2026-11-19 attended run, round 1, group 2): branch burndown/interrupt-signal-rules.

    Issues: #4146, #4100, #4218.

    Predicted file set:

    • CODESTYLE.md
    • host-setup/agent-safety/global_rules.py
    • tests/test_global_rules.py
    • scripts/docker_lint.py
    • tests/test_docker_lint.py

    Generated from those: the include regions in .agents/skills/python-codestyle/SKILL.md and .agents/skills/shell-codestyle/SKILL.md, and their .github/skills and .claude-plugin copies and source digests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions