Skip to content

gh-160700: Propagate InterruptedError from kqueue wait - #160714

Open
vankudothuadhinaik wants to merge 2 commits into
python:mainfrom
vankudothuadhinaik:fix-160700-kqueue-interrupted-error
Open

vankudothuadhinaik wants to merge 2 commits into
python:mainfrom
vankudothuadhinaik:fix-160700-kqueue-interrupted-error

Conversation

@vankudothuadhinaik

@vankudothuadhinaik vankudothuadhinaik commented Oct 26, 2026 •

Copy link
Copy Markdown

On macOS, Popen._wait_kqueue() catches OSError from kqueue.control() and falls back to polling. Since InterruptedError is an OSError subclass, this can swallow an exception raised by a Python signal handler instead of propagating it.

Explicitly re-raise InterruptedError while preserving fallback polling for other OSError failures. Add a kqueue-specific regression test.

Validation performed:

  • git diff --check: passed.
  • Focused kqueue regression: not run; the available Windows environment does not support kqueue and lacked a suitable checkout-built interpreter.
  • Native macOS testing: not performed.

The macOS-specific regression still needs validation in CPython CI.

@bedevere-app

bedevere-app Bot commented Oct 26, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@NikitaMikhailov

Copy link
Copy Markdown

LGTM. I tested the code at 95bcfc0 on macOS with a locally built debug interpreter:

  • The new regression test fails without the fix and passes with it, including 100 consecutive runs.
  • The full test_subprocess suite passes: 372 tests run, 54 skipped.
  • A separate reproducer using a real SIGALRM whose handler raises InterruptedError passes on five consecutive runs.

The change preserves the fallback for other OSError exceptions and the existing kqueue cleanup in finally.

AI tools assisted with this review and validation.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants