From 4536d03e829ca89496e8499cc29549cdb8c9bccb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Mon, 24 Feb 2025 21:35:43 -0800 Subject: [PATCH] FrameProcessor: cancel input/push tasks on CancelFrame --- src/pipecat/processors/frame_processor.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pipecat/processors/frame_processor.py b/src/pipecat/processors/frame_processor.py index f27c6d6c2..20a5071f4 100644 --- a/src/pipecat/processors/frame_processor.py +++ b/src/pipecat/processors/frame_processor.py @@ -240,7 +240,7 @@ class FrameProcessor: elif isinstance(frame, StopInterruptionFrame): self._should_report_ttfb = True elif isinstance(frame, CancelFrame): - self._cancelling = True + await self.__cancel(frame) async def push_error(self, error: ErrorFrame): await self.push_frame(error, FrameDirection.UPSTREAM) @@ -275,6 +275,11 @@ class FrameProcessor: self.__create_input_task() self.__create_push_task() + async def __cancel(self, frame: CancelFrame): + self._cancelling = True + await self.__cancel_input_task() + await self.__cancel_push_task() + # # Handle interruptions #