From 31311d8ac5be2e98f5462b227dfab5dbe1c6c6fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Tue, 1 Apr 2025 13:54:59 -0700 Subject: [PATCH] tests: fix test_user_idle_processor for python 3.10 --- src/pipecat/processors/user_idle_processor.py | 7 ++++--- tests/test_user_idle_processor.py | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/pipecat/processors/user_idle_processor.py b/src/pipecat/processors/user_idle_processor.py index e88df3540..e7b08f4a3 100644 --- a/src/pipecat/processors/user_idle_processor.py +++ b/src/pipecat/processors/user_idle_processor.py @@ -127,9 +127,10 @@ class UserIdleProcessor(FrameProcessor): # Check for end frames before processing if isinstance(frame, (EndFrame, CancelFrame)): - await self.push_frame(frame, direction) # Push the frame down the pipeline - if self._idle_task: - await self._stop() # Stop the idle task, if it exists + # Stop the idle task, if it exists + await self._stop() + # Push the frame down the pipeline + await self.push_frame(frame, direction) return await self.push_frame(frame, direction) diff --git a/tests/test_user_idle_processor.py b/tests/test_user_idle_processor.py index a2f2fd386..5f212e22b 100644 --- a/tests/test_user_idle_processor.py +++ b/tests/test_user_idle_processor.py @@ -71,6 +71,10 @@ class TestUserIdleProcessor(unittest.IsolatedAsyncioTestCase): SleepFrame(sleep=0.1), # Another bot speaking frame resets timer again BotSpeakingFrame(), + # Give some time for the idle timeout task to start (Python 3.10 + # doesn't really like when you create a task and then cancel it + # right away). + SleepFrame(sleep=0.1), ] expected_down_frames = [