Rename BaseTask → BaseWorker and reserve "task" for asyncio

Replaces every "task" identifier that referred to the BaseTask
abstraction with "worker". Asyncio task plumbing (asyncio.Task,
BaseTaskManager, TaskManager, create_task, cancel_task, etc.) stays
untouched. Highlights:

- Classes: BaseTask → BaseWorker, PipelineTask → PipelineWorker,
  LLMTask → LLMWorker, LLMContextTask → LLMContextWorker, TaskBus →
  WorkerBus, TaskRegistry → WorkerRegistry, TaskActivationArgs →
  WorkerActivationArgs, TaskReadyData → WorkerReadyData,
  TaskRegistryEntry → WorkerRegistryEntry, TaskObserver →
  WorkerObserver, all Bus*TaskMessage → Bus*WorkerMessage,
  BusAddTaskMessage.task field → worker, BusWorkerRegistryMessage.tasks
  field → workers.
- Methods/decorators: activate_task → activate_worker, deactivate_task
  → deactivate_worker, add_task → add_worker, watch_task →
  watch_worker, @task_ready → @worker_ready, setup_pipeline_task hook
  → setup_pipeline_worker.
- Params/fields: FrameProcessorSetup.pipeline_task and
  FunctionCallParams.pipeline_task → pipeline_worker. Parameter names
  like task_name → worker_name; spawn/run accept worker:.
- Files: pipeline/base_task.py → base_worker.py, pipeline/task.py →
  worker.py (plus a re-export shim at pipeline/task.py),
  task_observer.py → worker_observer.py, task_ready_decorator.py →
  worker_ready_decorator.py, pipecat.tasks → pipecat.workers,
  llm_task.py → llm_worker.py, llm_context_task.py →
  llm_context_worker.py, examples/multi-task → examples/multi-worker.

Back-compat:
- PipelineTask kept as a deprecated subclass of PipelineWorker that
  warns on construction.
- pipecat.pipeline.task re-exports PipelineWorker/PipelineTask/etc. so
  existing user imports keep working.
- FrameProcessor.pipeline_task kept as a deprecated property that
  forwards to pipeline_worker.

Local variables in examples that hold a worker (task = PipelineTask(...))
are renamed to worker = PipelineWorker(...). Asyncio-task locals
(runner_task, etc.) are preserved.
This commit is contained in:
Aleix Conchillo Flaqué
2026-05-20 16:39:45 -07:00
parent b9aed0d673
commit b03247f360
394 changed files with 4602 additions and 4487 deletions

View File

@@ -9,7 +9,7 @@ import itertools
import unittest
from pipecat.bus import (
BusAddTaskMessage,
BusAddWorkerMessage,
BusDataMessage,
BusEndMessage,
BusFrameMessage,
@@ -18,7 +18,7 @@ from pipecat.bus import (
)
from pipecat.bus.serializers import JSONMessageSerializer
from pipecat.frames.frames import TextFrame
from pipecat.pipeline.base_task import BaseTask
from pipecat.pipeline.base_worker import BaseWorker
from pipecat.processors.frame_processor import FrameDirection
from pipecat.utils.asyncio.task_manager import TaskManager, TaskManagerParams
@@ -133,8 +133,8 @@ class TestRedisBus(unittest.IsolatedAsyncioTestCase):
await self.bus.subscribe(_make_sub(received))
await self.bus.start()
task = BaseTask("test")
msg = BusAddTaskMessage(source="parent", task=task)
worker = BaseWorker("test")
msg = BusAddWorkerMessage(source="parent", worker=worker)
await self.bus.send(msg)
await asyncio.sleep(0.05)
@@ -144,8 +144,8 @@ class TestRedisBus(unittest.IsolatedAsyncioTestCase):
self.assertEqual(len(self.redis._published), 0)
# But delivered locally
self.assertEqual(len(received), 1)
self.assertIsInstance(received[0], BusAddTaskMessage)
self.assertIs(received[0].task, task)
self.assertIsInstance(received[0], BusAddWorkerMessage)
self.assertIs(received[0].worker, worker)
async def test_round_trip_via_subscriber(self):
"""Messages published are received by subscribers."""
@@ -156,7 +156,7 @@ class TestRedisBus(unittest.IsolatedAsyncioTestCase):
msg = BusEndMessage(source="task_a", reason="done")
await self.bus.send(msg)
# Give the reader task time to process
# Give the reader worker time to process
await asyncio.sleep(0.1)
await self.bus.stop()
@@ -239,7 +239,7 @@ class TestRedisBus(unittest.IsolatedAsyncioTestCase):
self.assertEqual(self.redis._published[0][0], "custom:channel")
async def test_stop_cleans_up(self):
"""stop() cancels the reader task and unsubscribes from Redis."""
"""stop() cancels the reader worker and unsubscribes from Redis."""
await self.bus.start()
self.assertIsNotNone(self.bus._pubsub)
self.assertIsNotNone(self.bus._reader_task)