From bc21a0b81799ccb5dadc123d2d53c24d5e9cdec3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Wed, 5 Feb 2025 18:33:03 -0800 Subject: [PATCH] FrameProcessor: add an error about missing super().process_frame(...) --- src/pipecat/processors/frame_processor.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/pipecat/processors/frame_processor.py b/src/pipecat/processors/frame_processor.py index 260e53ef2..3fb515a87 100644 --- a/src/pipecat/processors/frame_processor.py +++ b/src/pipecat/processors/frame_processor.py @@ -245,6 +245,9 @@ class FrameProcessor: await self.push_frame(error, FrameDirection.UPSTREAM) async def push_frame(self, frame: Frame, direction: FrameDirection = FrameDirection.DOWNSTREAM): + if not self._check_ready(frame): + return + if isinstance(frame, SystemFrame): await self.__internal_push_frame(frame, direction) else: @@ -319,6 +322,16 @@ class FrameProcessor: await self.push_error(ErrorFrame(str(e))) raise + def _check_ready(self, frame: Frame): + # If we are trying to push a frame but we still have no clock, it means + # we didn't process a StartFrame. + if not self._clock: + logger.error( + f"{self} not properly initialized, missing super().process_frame(frame, direction)?" + ) + return False + return True + def __create_input_task(self): if not self.__input_frame_task: self.__should_block_frames = False