From d7e1389497acd4050b043ffa4752bbcd63a50c73 Mon Sep 17 00:00:00 2001 From: Mark Backman Date: Tue, 16 Sep 2025 09:13:06 -0400 Subject: [PATCH] fix: clean up how UserIdleProcessor handles return False --- CHANGELOG.md | 4 ++++ src/pipecat/processors/user_idle_processor.py | 9 +++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c56f58491..e882d7408 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### 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 when a bot speaks and user input is blocked. diff --git a/src/pipecat/processors/user_idle_processor.py b/src/pipecat/processors/user_idle_processor.py index 406ccc885..f8e8cd7bc 100644 --- a/src/pipecat/processors/user_idle_processor.py +++ b/src/pipecat/processors/user_idle_processor.py @@ -17,7 +17,6 @@ from pipecat.frames.frames import ( Frame, FunctionCallInProgressFrame, FunctionCallResultFrame, - StartFrame, UserStartedSpeakingFrame, UserStoppedSpeakingFrame, ) @@ -185,15 +184,13 @@ class UserIdleProcessor(FrameProcessor): Runs in a loop until cancelled or callback indicates completion. """ - while True: + running = True + while running: try: await asyncio.wait_for(self._idle_event.wait(), timeout=self._timeout) except asyncio.TimeoutError: if not self._interrupted: self._retry_count += 1 - should_continue = await self._callback(self, self._retry_count) - if not should_continue: - await self._stop() - break + running = await self._callback(self, self._retry_count) finally: self._idle_event.clear()