Register the worker with PipelineRunner.add_workers() before calling run() instead. The worker argument still works but now emits a DeprecationWarning and will be removed in a future release. Update the runner docstrings, the run_test() helper, and all examples (including the asyncio.gather() forms) to use the new pattern.
45 lines
1.1 KiB
Python
45 lines
1.1 KiB
Python
#
|
|
# Copyright (c) 2024-2026, Daily
|
|
#
|
|
# SPDX-License-Identifier: BSD 2-Clause License
|
|
#
|
|
|
|
import asyncio
|
|
import sys
|
|
|
|
from loguru import logger
|
|
|
|
from pipecat.frames.frames import Frame
|
|
from pipecat.pipeline.pipeline import Pipeline
|
|
from pipecat.pipeline.runner import PipelineRunner
|
|
from pipecat.pipeline.worker import PipelineParams, PipelineWorker
|
|
from pipecat.processors.frame_processor import FrameDirection, FrameProcessor
|
|
|
|
logger.remove(0)
|
|
logger.add(sys.stderr, level="DEBUG")
|
|
|
|
|
|
class NullProcessor(FrameProcessor):
|
|
async def process_frame(self, frame: Frame, direction: FrameDirection):
|
|
await super().process_frame(frame, direction)
|
|
|
|
|
|
async def main():
|
|
"""This test shows heartbeat monitoring.
|
|
|
|
A warning is dispalyed when heartbeats are not received within the
|
|
default (5 seconds) timeout.
|
|
"""
|
|
pipeline = Pipeline([NullProcessor()])
|
|
|
|
worker = PipelineWorker(pipeline, params=PipelineParams(enable_heartbeats=True))
|
|
|
|
runner = PipelineRunner()
|
|
|
|
await runner.add_workers(worker)
|
|
await runner.run()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|