base_object
Base object class providing event handling and lifecycle management.
This module provides the foundational BaseObject class that offers common functionality including unique identification, naming, event handling, and async cleanup for all Pipecat components.
- class pipecat.utils.base_object.EventHandler(name: str, handlers: list[Any], is_sync: bool)[source]
Bases:
objectData class to store event handlers information.
This data class stores the event name, a list of handlers to run for this event, and whether these handlers will be executed in a task.
- Parameters:
name (str) – The name of the event handler.
handlers (List[Any]) – A list of functions to be called when this event is triggered.
is_sync (bool) – Indicates whether the functions are executed in a task.
- name: str
- handlers: list[Any]
- is_sync: bool
- class pipecat.utils.base_object.BaseObject(*, name: str | None = None, **kwargs)[source]
Bases:
ABCAbstract base class providing common functionality for Pipecat objects.
Provides unique identification, naming, event handling capabilities, and async lifecycle management for all Pipecat components. All major classes in the framework should inherit from this base class.
- __init__(*, name: str | None = None, **kwargs)[source]
Initialize the base object.
- Parameters:
name – Optional custom name for the object. If not provided, generates a name using the class name and instance count.
**kwargs – Additional arguments passed to parent class.
- property id: int
Get the unique identifier for this object.
- Returns:
The unique integer ID assigned to this object instance.
- property name: str
Get the name of this object.
- Returns:
The object’s name, either custom-provided or auto-generated.
- async cleanup()[source]
Clean up resources and wait for running event handlers to complete.
This method should be called when the object is no longer needed. It waits for all currently executing event handler tasks to finish before returning.