Bug fix: _play_speech get stuck due to orphan speech handle. #1555
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.
When a new _synthesize_answer_task is created, it is possible that the old _synthesize_answer_task is waiting for the llm_stream at
In this case, the new task will cancel the old one. However, the handle of the old task is not correctly canceled.
This would result in the handle never being initialized by
_synthesize_answer_task
.As a result, the
_play_speech
function will stuck atawait speech_handle.wait_for_initialization()
, and blocks all the subsequent speeches.Note that the old handle is supposed to be canceled by
self._pending_agent_reply.cancel()
in the_synthesize_agent_reply function
. However, this is not working properly sinceself._pending_agent_reply
is assigned toNone
in the_validate_reply_if_possible
function.