Skip to content

Other Captured subprocess.run Timeouts Can Outlast Their Deadline on Windows #3854

Done

Description

@ptr727

On Windows, subprocess.run with capture_output and a timeout kills only the direct child at the deadline. It then calls communicate() again with no bound and waits for the pipes to close. A child started by that child still holds them, so the deadline does not hold.

Measured

The fix for #1754 measured this on native Windows through git_in in scripts/skills_install.py. A 3-second deadline over git -c alias.stall='!sleep 20' stall, reached through Git for Windows' cmd\git.exe launcher, returned after 20.1 seconds, the length of the stall. With a helper that kills the tree and bounds the final collection, the same case returned after 3.2 seconds. POSIX is not affected the same way, since subprocess.run there waits for the child rather than for the pipes.

Sites with the same call shape

These run a git launcher or a resolved tool under a captured subprocess.run with a timeout. None of them was measured, and a site is affected only where its child can stall with a descendant holding the pipes.

  • scripts/pr_review.py, _run, which _git calls for its read-only git commands
  • scripts/pr_cleanup.py, its git -C runner
  • scripts/local_review.py, its git runner
  • scripts/local_review.py, the coderabbit backend, whose path comes from shutil.which and can be a .cmd
  • scripts/host_gate.py, probe
  • scripts/docker_lint.py, its command runner, which also runs docker rm --force after a timeout

What to do

Move run_with_deadline and kill_process_tree out of scripts/skills_install.py into one shared module, and move each site that can reach this onto it. Each site keeps its own timeout and decoding, so the shared form takes them as arguments. A site that cannot stall this way is named here with the reason rather than moved.

A fix counts as verified once a site's stalled case runs on native Windows or on the hosted Windows job. RunWithDeadlineCase in tests/test_skills_install.py has the process tree to reuse, including the close_fds=False launch that a real pipe holder needs.

Activity

  1. added
    bug
    pre-existing
    on Nov 4, 2026
  2. ptr727 commented on Nov 23, 2026

    @ptr727
    OwnerAuthor

    Backlog burndown claim (round 5, 2026-11-23): branch burndown/shared-run-deadline.

    Predicted files: scripts/skills_install.py, scripts/run_deadline.py (new), scripts/pr_review.py, scripts/pr_cleanup.py, scripts/local_review.py, scripts/host_gate.py, scripts/docker_lint.py, tests/test_skills_install.py, tests/test_pr_review.py, scripts/README.md, tests/test_tooling_encoding.py (added 2026-11-24 so the UTF-8 decode gate reaches the moved sites).

    Group issues: #3854.

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

    bugpre-existing

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions