spdl.pipeline.BackgroundTask¶
- class BackgroundTask[source]¶
A background task that runs alongside pipeline stages.
Subclass this and override
run()to implement custom logic. The task is started when the pipeline starts and cancelled when the pipeline completes. Errors are logged but do not cause the pipeline to fail.Example:
class MyMonitor(BackgroundTask): async def run(self) -> None: while True: collect_metrics() await asyncio.sleep(60) pipeline = build_pipeline(cfg, num_threads=4, background_tasks=[MyMonitor])
Methods
run()Override this to implement the background task logic.