From d22d2da03d5eeae7243536a5322b046c6ed94d53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Tue, 5 Aug 2025 16:17:03 -0700 Subject: [PATCH 1/2] PipelineTask: always try to cancel things In a previous commit we only cleanup things if the user run `task.cancel()`. However, if the task finishes cleanly we were not cancelling anything. --- src/pipecat/pipeline/task.py | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/pipecat/pipeline/task.py b/src/pipecat/pipeline/task.py index 1640d589c..1d9d642e0 100644 --- a/src/pipecat/pipeline/task.py +++ b/src/pipecat/pipeline/task.py @@ -459,20 +459,10 @@ class PipelineTask(BasePipelineTask): # awaiting a task. pass finally: - # We only cancel things cleanly if we know we are the ones - # cancelling. It's possibe that we get an asyncio.CancelledError - # from the outside, in which case it is very likely other tasks have - # been already cancelled (e.g. when python is shutting down) so we - # can't assume things are being cancelled nicely. - if self._cancelled: - await self._cancel_tasks() - await self._cleanup(cleanup_pipeline) - if self._check_dangling_tasks: - self._print_dangling_tasks() - else: - logger.warning( - f"Pipeline task {self} is not being cancelled properly (use cancel() method)" - ) + await self._cancel_tasks() + await self._cleanup(cleanup_pipeline) + if self._check_dangling_tasks: + self._print_dangling_tasks() self._finished = True async def queue_frame(self, frame: Frame): From 313fdc92a1ef09a02db347b2d45cd1c042735ec2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Tue, 5 Aug 2025 16:25:16 -0700 Subject: [PATCH 2/2] DailyRunnerArguments: make body optional --- src/pipecat/runner/run.py | 4 ++-- src/pipecat/runner/types.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pipecat/runner/run.py b/src/pipecat/runner/run.py index ff4a09c35..eb45091b8 100644 --- a/src/pipecat/runner/run.py +++ b/src/pipecat/runner/run.py @@ -265,7 +265,7 @@ def _setup_daily_routes(app: FastAPI): # Start the bot in the background with empty body for GET requests bot_module = _get_bot_module() - runner_args = DailyRunnerArguments(room_url=room_url, token=token, body={}) + runner_args = DailyRunnerArguments(room_url=room_url, token=token) runner_args.handle_sigint = False asyncio.create_task(bot_module.bot(runner_args)) return RedirectResponse(room_url) @@ -395,7 +395,7 @@ async def _run_daily_direct(): room_url, token = await configure(session) # Direct connections have no request body, so use empty dict - runner_args = DailyRunnerArguments(room_url=room_url, token=token, body={}) + runner_args = DailyRunnerArguments(room_url=room_url, token=token) # Get the bot module and run it directly bot_module = _get_bot_module() diff --git a/src/pipecat/runner/types.py b/src/pipecat/runner/types.py index 95048817e..49ee71cf4 100644 --- a/src/pipecat/runner/types.py +++ b/src/pipecat/runner/types.py @@ -39,8 +39,8 @@ class DailyRunnerArguments(RunnerArguments): """ room_url: str - token: Optional[str] - body: Any + token: Optional[str] = None + body: Optional[Any] = {} @dataclass