
    qih                         d Z ddlZddlmZ ddlmZ ddlmZmZ ddl	m
Z
 ddlmZ e G d d	             Z G d
 de      Zy)zBase pipeline task implementation for managing pipeline execution.

This module provides the abstract base class and configuration for pipeline
tasks that manage the lifecycle and execution of frame processing pipelines.
    N)abstractmethod)	dataclass)AsyncIterableIterable)Frame)
BaseObjectc                   0    e Zd ZU dZej
                  ed<   y)PipelineTaskParamszConfiguration parameters for pipeline task execution.

    Parameters:
        loop: The asyncio event loop to use for task execution.
    loopN)__name__
__module____qualname____doc__asyncioAbstractEventLoop__annotations__     L/opt/pipecat/venv/lib/python3.12/site-packages/pipecat/pipeline/base_task.pyr
   r
      s     
#
##r   r
   c                       e Zd ZdZedefd       Zed        Zed        Zede	fd       Z
edefd	       Zed
ee   ee   z  fd       Zy)BasePipelineTaskzAbstract base class for pipeline task implementations.

    Defines the interface for managing pipeline execution lifecycle,
    including starting, stopping, and frame queuing operations.
    returnc                      y)zCheck if the pipeline task has finished execution.

        Returns:
            True if all processors have stopped and the task is complete.
        Nr   selfs    r   has_finishedzBasePipelineTask.has_finished(   s     	r   c                    K   yw)zSchedule the pipeline to stop after processing all queued frames.

        Implementing classes should send an EndFrame or equivalent signal to
        gracefully terminate the pipeline once all current processing is complete.
        Nr   r   s    r   stop_when_donezBasePipelineTask.stop_when_done1         	   c                    K   yw)zImmediately stop the running pipeline.

        Implementing classes should cancel all running tasks and stop frame
        processing without waiting for completion.
        Nr   r   s    r   cancelzBasePipelineTask.cancel:   r   r    paramsc                    K   yw)a  Start and run the pipeline with the given parameters.

        Implementing classes should initialize and execute the pipeline using
        the provided configuration parameters.

        Args:
            params: Configuration parameters for pipeline execution.
        Nr   )r   r#   s     r   runzBasePipelineTask.runC         	r    framec                    K   yw)zQueue a single frame for processing by the pipeline.

        Implementing classes should add the frame to their processing queue
        for downstream handling.

        Args:
            frame: The frame to be processed.
        Nr   )r   r'   s     r   queue_framezBasePipelineTask.queue_frameO   r&   r    framesc                    K   yw)a  Queue multiple frames for processing by the pipeline.

        Implementing classes should process the iterable/async iterable and
        add all frames to their processing queue.

        Args:
            frames: An iterable or async iterable of frames to be processed.
        Nr   )r   r*   s     r   queue_frameszBasePipelineTask.queue_frames[   r&   r    N)r   r   r   r   r   boolr   r   r"   r
   r%   r   r)   r   r   r,   r   r   r   r   r   !   s     d       	 2 	 	 	u 	 	 	%=;O)O 	 	r   r   )r   r   abcr   dataclassesr   typingr   r   pipecat.frames.framesr   pipecat.utils.base_objectr   r
   r   r   r   r   <module>r3      sE      ! * ' 0 $ $ $Dz Dr   