Skip to content

Preserve subprocesses after output stream errors - #22573

Draft
desertaxle wants to merge 1 commit into
mainfrom
codex/anyio-4-14-2-compatibility
Draft

Preserve subprocesses after output stream errors#22573
desertaxle wants to merge 1 commit into
mainfrom
codex/anyio-4-14-2-compatibility

Conversation

@desertaxle

Copy link
Copy Markdown
Member

this PR keeps subprocesses running to completion when stdout or stderr forwarding fails, restoring compatibility with AnyIO 4.14.2.

Details

AnyIO 4.14.2 closes underlying subprocess pipe transports during cleanup. When Prefect's output consumer raises, that cleanup can terminate the flow process before it records a final state.

run_process now drains both pipes without forwarding their output and waits for the process to exit before re-raising the original streaming error. Cancellation continues through the existing termination path because the fallback handles only ordinary exceptions.

The regression emits one megabyte to each output stream after forcing a forwarding failure and verifies that the child still reaches completion. The focused process utility and runner tests pass with both AnyIO 4.14.1 and 4.14.2.

@codspeed-hq

codspeed-hq Bot commented Jul 21, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 8 untouched benchmarks
⏩ 1 skipped benchmark1


Comparing codex/anyio-4-14-2-compatibility (20bb144) with main (4b510e4)

Open in CodSpeed

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

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.

1 participant