fix(helpers): propagate audio stream producer errors - #3817
Open
Hughhhhcoder wants to merge 1 commit into
Open
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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.
Changes being requested
LocalAudioPlayer.play_stream()currently waits only for the audio callback's completion event before it awaits the input producer task. If the supplied async generator raises, the producer task finishes with that exception but no one sets the playback event, so the public method hangs and asyncio reports that the task exception was never retrieved.This change waits for playback completion and producer completion together. A producer failure is propagated immediately; normal producer completion still waits for the callback to consume the queued completion sentinel, so buffered playback behavior is unchanged. The cleanup path also cancels and retrieves either internal task when the caller exits early.
A hardware-free regression replaces
sounddevice.OutputStreamwith a silent context manager and verifies that a synthetic input-generator failure reaches the caller instead of timing out.Validation:
uv run --locked --all-extras pytest -q tests/test_local_audio_player.py tests/lib/test_audio.py— 5 passed on Python 3.10.uv run --isolated --python 3.14— 5 passed../scripts/lintwith the repository-pinned Node.js 22.22.3 — Ruff passed; Pyright reported 0 errors; Mypy reported no issues in 1614 source files; import check passed.main: the same input timed out after 200 ms and emittedTask exception was never retrievedfor the originalRuntimeError.The generated API audio tests require the repository's Steady mock server. They were not counted as passing in this environment; without that server they returned HTTP 502 before exercising this helper.
Additional context & links
The affected file is under
src/openai/helpers/, whichCONTRIBUTING.mdidentifies as hand-maintained code. I searched open and closed issues and pull requests forplay_streamproducer failures and did not find an existing fix. Existing audio-helper PRs concernget_running_loop()or array shape handling rather than this failure path.