Merge pull request #4440 from pipecat-ai/filipi/daily_send_message_issue

Fixing a race condition when cleaning up the daily transport.
This commit is contained in:
Filipi da Silva Fuchter
2026-05-07 13:09:53 -03:00
committed by GitHub
2 changed files with 9 additions and 0 deletions

1
changelog/4440.fixed.md Normal file
View File

@@ -0,0 +1 @@
- Fixed a race condition in the Daily transport that caused `AttributeError: 'NoneType' object has no attribute 'send_app_message'` when tearing down a pipeline. Both `DailyInputTransport` and `DailyOutputTransport` share the same `DailyTransportClient` and both call `cleanup()`, which was releasing the underlying `CallClient` on the first call — leaving the second caller with a `None` client.

View File

@@ -526,6 +526,7 @@ class DailyTransportClient(EventHandler):
self._joined = False
self._joined_event = asyncio.Event()
self._leave_counter = 0
self._cleanup_counter = 0
self._task_manager: BaseTaskManager | None = None
@@ -741,6 +742,7 @@ class DailyTransportClient(EventHandler):
Args:
setup: The frame processor setup configuration.
"""
self._cleanup_counter += 1
if self._task_manager:
return
@@ -754,6 +756,12 @@ class DailyTransportClient(EventHandler):
async def cleanup(self):
"""Cleanup client resources and cancel tasks."""
# Decrement cleanup counter. DailyInputTransport and DailyOutputTransport
# share this client and both call cleanup(), so only run on the last call.
self._cleanup_counter -= 1
if self._cleanup_counter > 0:
return
if self._event_task and self._task_manager:
await self._task_manager.cancel_task(self._event_task)
self._event_task = None