-
Notifications
You must be signed in to change notification settings - Fork 4.4k
fix: resolve voice pipeline deadlock on TTS error and retrieve background task exceptions #3921
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -194,8 +194,10 @@ async def _stream_audio( | |
| ) | ||
| logger.error("Error streaming audio: %s", e) | ||
|
|
||
| # Signal completion for whole session because of error | ||
| await local_queue.put(VoiceStreamEventLifecycle(event="session_ended")) | ||
| await self._add_error(e) | ||
| await local_queue.put(None) | ||
| if self.text_generation_task is not None and not self.text_generation_task.done(): | ||
| self.text_generation_task.cancel() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a TTS segment fails while the streamed multi-turn producer is between turns or waiting on transcription/workflow, this cancellation makes AGENTS.md reference: AGENTS.md:L110-L110 Useful? React with 👍 / 👎. |
||
| raise e | ||
|
|
||
| async def _add_text(self, text: str): | ||
|
|
@@ -292,8 +294,11 @@ def _cleanup_tasks(self): | |
| self.text_generation_task.cancel() | ||
|
|
||
| def _check_errors(self): | ||
| for task in self._tasks: | ||
| if task.done(): | ||
| all_tasks = list(self._tasks) | ||
| if self.text_generation_task is not None: | ||
| all_tasks.append(self.text_generation_task) | ||
| for task in all_tasks: | ||
| if task.done() and not task.cancelled(): | ||
| if task.exception(): | ||
| self._stored_exception = task.exception() | ||
| break | ||
|
Comment on lines
+300
to
304
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a TTS segment fails during a pipeline run, the segment task and AGENTS.md reference: AGENTS.md:L109-L110 Useful? React with 👍 / 👎. |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a later TTS segment fails faster than an earlier segment, this puts the terminal error directly on the public queue instead of going through
_ordered_tasks/_dispatch_audio. Becausestream()stops as soon as it readsVoiceStreamEventError, consumers can miss already-started earlier audio and lifecycle events whenever concurrent segment synthesis completes out of order; route the terminal error through the ordered path, or otherwise wait for earlier local queues before publishing it.AGENTS.md reference: AGENTS.md:L109-L110
Useful? React with 👍 / 👎.