Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions livekit-agents/livekit/agents/voice/speech_handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,13 @@ def _mark_generation_done(self) -> None:

def _mark_done(self) -> None:
with contextlib.suppress(asyncio.InvalidStateError):
# will raise InvalidStateError if the future is already done (interrupted)
self._done_fut.set_result(None)
if self._generations:
self._mark_generation_done() # preemptive generation could be cancelled before being scheduled

# must be outside the _done_fut suppress block: if _done_fut is already
# done, InvalidStateError would suppress the entire block and skip this,
# leaving the generation future unresolved and _wait_for_generation stuck.
if self._generations:
self._mark_generation_done()

if self._interrupt_timeout_handle is not None:
self._interrupt_timeout_handle.cancel()
Expand Down
Loading