Repository navigation
Fix a 5 second delay for the first listener on an idle serve worker - #316
Merged
Merged
Conversation
With multiple workers, a listener joining a worker with no other listeners heard nothing for about 5 seconds.
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Mock-only tests do not verify the pinned aiosendspin PushStream history and timestamp semantics needed for prompt, synchronized playback when joining an idle worker in a real multi-worker session.
No open issues 🎉
What changed in this PR
Fixes the roughly five-second playback delay when the first listener joins an idle worker while another worker is already playing in sendspin serve --workers.
Changes:
- Retains unplayed audio without encoding it and supplies it as history when a new stream starts.
- Discards expired chunks and clears retained audio when the source timeline changes.
- Adds tests for replaying recent audio and excluding chunks from a previous timeline.
| File | Description |
|---|---|
tests/serve/test_worker.py |
Tests historical audio replay and timeline reset handling. |
sendspin/serve/worker.py |
Buffers unplayed audio and prepares it for newly active streams. |
Review effort: Balanced
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.
What does this implement/fix?
With
sendspin serve --workers, a listener joining a worker that had no other listeners heard nothing for about 5 seconds while another worker was already playing. The idle worker dropped all audio until its first listener arrived, so the first audio it sent was scheduled about 5 seconds ahead.Workers now keep the audio that hasn't played yet, without encoding it, and hand it to a new stream so playback starts right away.
Related issue (if applicable):
Types of changes
bugfixnew-featureenhancementbreaking-changerefactordocumentationmaintenancecidependencies