From 699ca38dc173f48d2c7e72afb825fe60591d73e5 Mon Sep 17 00:00:00 2001 From: filipi87 Date: Thu, 9 Apr 2026 09:03:06 -0300 Subject: [PATCH] Allowing to check if a specific frame is in the queue. --- src/pipecat/processors/frame_processor.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/pipecat/processors/frame_processor.py b/src/pipecat/processors/frame_processor.py index fe9e5b90f..77a35fb29 100644 --- a/src/pipecat/processors/frame_processor.py +++ b/src/pipecat/processors/frame_processor.py @@ -25,6 +25,7 @@ from typing import ( Optional, Tuple, Type, + Union, ) from loguru import logger @@ -928,6 +929,21 @@ class FrameProcessor(BaseObject): """Reset non-system frame processing queue.""" self.__process_queue.reset() + def has_queued_frame(self, frame_type: Union[Type[Frame], Type[UninterruptibleFrame]]) -> bool: + """Return True if a frame of the given type is waiting in the processing queue. + + Delegates to :meth:`FrameQueue.has_frame` so the check is O(distinct + enqueued types) with no queue scanning. ``frame_type`` may be any + ``Frame`` subclass or ``UninterruptibleFrame`` (a mixin). + + Args: + frame_type: The frame class (or mixin) to look for. + + Returns: + True if at least one matching frame is queued. + """ + return self.__process_queue.has_frame(frame_type) + async def __cancel_process_task(self): """Cancel the non-system frame processing task.""" if self.__process_frame_task: