Merge pull request #1144 from pipecat-ai/aleix/frame-processor-missing-init-warning

FrameProcessor: add an error about missing super().process_frame(...)
This commit is contained in:
Aleix Conchillo Flaqué
2025-02-06 07:18:35 -08:00
committed by GitHub

View File

@@ -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