From 4b3c776f582ce708ddb2e2b93fb772a499649dd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Fri, 17 Jan 2025 10:04:24 -0800 Subject: [PATCH] task: don't use push queue to send a heartbeat This is because we might be waiting for the EndFrame. Currently, if we push an EndFrame to the task, the task will block until the EndFrame traverses all the pipeline. --- src/pipecat/pipeline/task.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pipecat/pipeline/task.py b/src/pipecat/pipeline/task.py index a77997d08..9a6d344ea 100644 --- a/src/pipecat/pipeline/task.py +++ b/src/pipecat/pipeline/task.py @@ -338,7 +338,10 @@ class PipelineTask: """ while True: try: - await self.queue_frame(HeartbeatFrame(timestamp=self._clock.get_time())) + # Don't use `queue_frame()` because if an EndFrame is queued the + # task will just stop waiting for the pipeline to finish not + # allowing more frames to be pushed. + await self._source.queue_frame(HeartbeatFrame(timestamp=self._clock.get_time())) await asyncio.sleep(HEARTBEAT_SECONDS) except asyncio.CancelledError: break