frame_queue
Frame queue utilities for Pipecat pipeline processors.
- class pipecat.utils.frame_queue.FrameQueue(frame_getter: ~collections.abc.Callable[[~typing.Any], ~pipecat.frames.frames.Frame | None] = <function FrameQueue.<lambda>>)[source]
Bases:
QueueAn asyncio.Queue that knows whether any uninterruptible frame is enqueued.
Extends
asyncio.Queuewithhas_uninterruptible, so interrupt-handling code can decide whether to cancel a task or merely drain the interruptible items, and withreset(), which does that draining: it removes every interruptible item and keeps the uninterruptible ones (Frame.interruptibleFalse) in place. Both read the frames’ flags as they are at that moment.Items may be raw
Frameobjects or tuples whose first element is aFrame(e.g.(frame, direction, callback)). Pass aframe_gettercallable to extract the frame from each item; the default treats the item itself as the frame. Queues that also carry non-frame items should returnNonefrom their getter for those.- __init__(frame_getter: ~collections.abc.Callable[[~typing.Any], ~pipecat.frames.frames.Frame | None] = <function FrameQueue.<lambda>>)[source]
Initialize the FrameQueue.
- Parameters:
frame_getter – Callable that extracts a
Framefrom a queue item, orNonewhen the item holds no frame. Defaults to the identity function (item is a rawFrame). Passlambda item: item[0]when items are(frame, direction, callback)tuples.
- has_frame(frame_type: type[Frame]) bool[source]
Return True if any frame of the given type is in the queue.
Note
This inspects the internal _queue (deque) of asyncio.Queue. This is not part of the public API but is stable in CPython.
- Parameters:
frame_type – The frame class to check for.
- Returns:
True if at least one enqueued frame is an instance of
frame_type.