Skip to content

Ignore a Second SIGTERM in pr_review.py So an Interrupt Prints One Line #4415

Done

Description

@ptr727

Problem

scripts/pr_review.py prints a chained traceback instead of one interrupted line when it is stopped by a SIGTERM that arrives twice.

on_sigterm (near line 2178) raises KeyboardInterrupt(signum) and stays installed while the except KeyboardInterrupt block in __main__ prints pr_review.py: interrupted by .... A second SIGTERM during that print raises again inside the handler, and Python reports KeyboardInterrupt: 15 with "During handling of the above exception, another exception occurred".

A second SIGTERM is the ordinary case under timeout <n> uv run --no-project --script scripts/pr_review.py wait .... The signal reaches both uv and the Python child, and uv forwards its own copy.

CODESTYLE.md "Interrupts in Python" requires that a later signal return at once and that the script print one line with no traceback.

Evidence

Two independent wait runs in the 2026-11-24 away burndown hit their outer timeout bound, and both showed the same chained traceback from on_sigterm, raised inside the interrupted by print.

Done looks like

  • A second SIGTERM or SIGINT after the first is ignored, or returns at once, so the script prints exactly one interrupted by line and no traceback.
  • A test sends two SIGTERMs to the script and asserts that single line.

Activity

  1. ptr727 commented on Nov 24, 2026

    @ptr727
    OwnerAuthor

    Released (2026-11-24): PR #4417 merged to develop at 64465d7; branch and worktree cleaned up, so this claim holds no files. The issue closes on promotion.

    Backlog burndown claim (away run 2026-11-24, round 3, refill): branch burndown/pr-review-second-signal, issue #4415.

    Per CODESTYLE.md "Interrupts in Python": one handler for SIGINT and SIGTERM that records the first signal, raises KeyboardInterrupt, and returns at once on any later one, with SIGINT taken only where signal.getsignal(signal.SIGINT) is still signal.default_int_handler. The other hub scripts (prose_lint.py, hub_fetch_run.py, backlog_metrics.py, docker_lint.py, secrets_sync.py) already have this shape, so scripts/pr_review.py is the whole class.

    Predicted files:

    • scripts/pr_review.py, on_sigterm and the __main__ block.
    • tests/test_pr_review.py, a two-SIGTERM case beside the existing SIGTERM-mid-wait test, asserting one interrupted by SIGTERM line and death by the signal.
    • At most one existing scripts/pr_review_*.py sibling, as the target of any relocation the size ceiling forces. tests/test_pr_review_size.py holds pr_review.py under 2200 lines, and the file is at 2197 on develop. The ceiling is not raised.

    scripts/README.md is not in this claim. It is held by burndown/docker-lint-digest-pins, so a relocation that makes its module descriptions untrue needs that file and waits.

    Any other group needing one of these files waits for this branch to merge.

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