fix race condition when stop background audio play handle#4197
Merged
Conversation
chenghao-mou
approved these changes
Dec 8, 2025
| await gen.aclose() | ||
| with contextlib.suppress(RuntimeError): | ||
| await gen.aclose() | ||
| stopped = True |
Member
There was a problem hiding this comment.
Nitpicking: should this be set before the aclose call?
theomonnom
reviewed
Dec 8, 2025
| else: | ||
| sound = audio_frames_from_file(sound) | ||
|
|
||
| stopped = False |
Member
There was a problem hiding this comment.
Do we even need the stopped flag if we just ignore the RuntimError?
Contributor
Author
There was a problem hiding this comment.
Is that okay to just ignore the runtime error, the generator is still not closed? I am wondering should we also close the generator from audio file?
theomonnom
approved these changes
Dec 8, 2025
meetakshay99
added a commit
to meetakshay99/agents
that referenced
this pull request
Dec 12, 2025
* main: (267 commits) AGT-2328: negative threshold in silero (livekit#4228) disable interruptions for agent greeting (livekit#4223) feature: GPT-5.2 support (livekit#4235) turn-detector: remove english model from readme (livekit#4233) add keep alive task for liveavatar plugin (livekit#4231) feat(warm-transfer): add sip_number parameter for outbound caller ID (livekit#4216) fix blocked send task in liveavatar plugin (livekit#4214) clear _q_updated right after await to avoid race conditions (livekit#4209) ensure playback_segments_count is consistent in the audio output chain (livekit#4211) fix inworld punctuation handling (livekit#4215) Inference: Rename fallback model name param (livekit#4202) fix race condition when stop background audio play handle (livekit#4197) fix watchfiles prevent agent prcoess exit on sigterm (livekit#4194) feat(google): add streaming support for Gemini TTS models (livekit#4189) Add LiveAvatar Stop Session API Call + README Fix (livekit#4195) Fallback API for Inference (livekit#4099) feat(rime): expand update_options to accept all TTS parameters (livekit#4095) mistralai models update (livekit#4156) fix record.exc_info is not pickable when using LogQueueHandler (livekit#4185) Restore otel chat message (livekit#4118) ...
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.
fix #3606, the issue was caused by a race condition when
gen.aclose()is called duringstream.__anext__().needs livekit/python-sdks#537used a simpler solution that ignore the RuntimeError fromgen.acloseand add a stopped flag