fix: clean up how UserIdleProcessor handles return False
This commit is contained in:
@@ -27,6 +27,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed a self-cancellation deadlock in `UserIdleProcessor` when returning
|
||||||
|
`False` from an idle callback. The task now terminates naturally instead of
|
||||||
|
attempting to cancel itself.
|
||||||
|
|
||||||
- Fixed an issue in `AudioBufferProcessor` where a recording is not created
|
- Fixed an issue in `AudioBufferProcessor` where a recording is not created
|
||||||
when a bot speaks and user input is blocked.
|
when a bot speaks and user input is blocked.
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ from pipecat.frames.frames import (
|
|||||||
Frame,
|
Frame,
|
||||||
FunctionCallInProgressFrame,
|
FunctionCallInProgressFrame,
|
||||||
FunctionCallResultFrame,
|
FunctionCallResultFrame,
|
||||||
StartFrame,
|
|
||||||
UserStartedSpeakingFrame,
|
UserStartedSpeakingFrame,
|
||||||
UserStoppedSpeakingFrame,
|
UserStoppedSpeakingFrame,
|
||||||
)
|
)
|
||||||
@@ -185,15 +184,13 @@ class UserIdleProcessor(FrameProcessor):
|
|||||||
|
|
||||||
Runs in a loop until cancelled or callback indicates completion.
|
Runs in a loop until cancelled or callback indicates completion.
|
||||||
"""
|
"""
|
||||||
while True:
|
running = True
|
||||||
|
while running:
|
||||||
try:
|
try:
|
||||||
await asyncio.wait_for(self._idle_event.wait(), timeout=self._timeout)
|
await asyncio.wait_for(self._idle_event.wait(), timeout=self._timeout)
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
if not self._interrupted:
|
if not self._interrupted:
|
||||||
self._retry_count += 1
|
self._retry_count += 1
|
||||||
should_continue = await self._callback(self, self._retry_count)
|
running = await self._callback(self, self._retry_count)
|
||||||
if not should_continue:
|
|
||||||
await self._stop()
|
|
||||||
break
|
|
||||||
finally:
|
finally:
|
||||||
self._idle_event.clear()
|
self._idle_event.clear()
|
||||||
|
|||||||
Reference in New Issue
Block a user