Repository navigation
fix: keep stderr written before an async timeout - #6
Merged
Merged
Conversation
run_async wrapped communicate() in wait_for, so a timeout cancelled it and discarded the chunks it had already read: QsvTimeout.stderr from AsyncQsv held only what arrived after the kill, while Qsv kept it all. Let communicate() keep running through the kill and collect its output within kill_grace; if an escaped descendant still holds the pipes, drop the output as run_sync does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On timeout,
AsyncQsvraisedQsvTimeoutwith an empty or truncatedstderr, whileQsvkept everything qsv wrote before the deadline.run_asyncwrappedproc.communicate()inasyncio.wait_for. On timeout,wait_forcancels it, and the innerStreamReader.read(-1)collects chunks in a local list, so whatever it had already read was thrown away._timeout_cleanupthen only saw stderr arriving after the kill.Fix
run_asyncnow waits on thecommunicate()task withasyncio.wait(..., timeout=)and doesn't cancel it on timeout. The process tree is killed as before, then the still-running read is givenkill_graceto finish and its output is used. If a descendant that left the process group still holds the pipes, the read is cancelled and the output dropped, the same asrun_sync. Cancellation and teardown paths are otherwise unchanged.Tests
test_timeout_keeps_stderr_written_before_it(sync) andtest_async_timeout_keeps_stderr_written_before_it. The async one failed before the fix.--platform win32).🤖 Generated with Claude Code