Overview
PipelineTask
is the central class for managing pipeline execution. It handles the lifecycle of the pipeline, processes frames in both directions, manages task cancellation, and provides event handlers for monitoring pipeline activity.
Basic Usage
Constructor Parameters
The pipeline to execute.
Configuration parameters for the pipeline. See
PipelineParams for details.
List of observers for monitoring pipeline execution. See
Observers for details.
Clock implementation for timing operations.
Custom task manager for handling asyncio tasks. If None, a default TaskManager
is used.
Whether to check for processors’ tasks finishing properly.
Timeout in seconds before considering the pipeline idle. Set to None to
disable idle detection. See Pipeline Idle
Detection for details.
Frame types that should prevent the pipeline from being considered idle. See
Pipeline Idle Detection for
details.
Whether to automatically cancel the pipeline task when idle timeout is
reached. See Pipeline Idle
Detection for details.
Whether to enable OpenTelemetry tracing. See The OpenTelemetry guide for details.
Whether to enable turn tracking. See The OpenTelemetry guide for details.
Custom ID for the conversation. If not provided, a UUID will be generated. See The OpenTelemetry guide for details.
Any additional attributes to add to top-level OpenTelemetry conversation span. See The OpenTelemetry guide for details.
Methods
Task Lifecycle Management
Starts and manages the pipeline execution until completion or cancellation.
Sends an EndFrame to the pipeline to gracefully stop the task after all queued
frames have been processed.
Stops the running pipeline immediately by sending a CancelFrame.
Returns whether the task has finished (all processors have stopped).
Frame Management
Queues a single frame to be pushed down the pipeline.
Queues multiple frames to be pushed down the pipeline.
Event Handlers
PipelineTask provides an event handler that can be registered using theevent_handler
decorator:
on_idle_timeout
Triggered when no activity frames (as specified byidle_timeout_frames
) have been received within the idle timeout period.