fix: cancel pipeline on peer disconnect
This commit is contained in:
@@ -7,7 +7,7 @@ from loguru import logger
|
||||
from pipecat.frames.frames import (
|
||||
BotStartedSpeakingFrame,
|
||||
BotStoppedSpeakingFrame,
|
||||
EndFrame,
|
||||
CancelFrame,
|
||||
OutputTransportMessageUrgentFrame,
|
||||
TTSSpeakFrame,
|
||||
)
|
||||
@@ -218,8 +218,11 @@ def bind_cascade_pipeline_events(
|
||||
|
||||
@transport.event_handler("on_client_disconnected")
|
||||
async def on_client_disconnected(_transport, _client):
|
||||
logger.info("对端断开,结束管线")
|
||||
await worker.queue_frame(EndFrame())
|
||||
# The peer can no longer consume queued audio. EndFrame would wait for
|
||||
# graceful playback and can deadlock on SmallWebRTC's pending audio
|
||||
# future, so a transport disconnect must stop output immediately.
|
||||
logger.info("对端断开,立即取消管线")
|
||||
await worker.queue_frame(CancelFrame(reason="client_disconnected"))
|
||||
|
||||
|
||||
def bind_realtime_pipeline_events(
|
||||
@@ -296,5 +299,5 @@ def bind_realtime_pipeline_events(
|
||||
|
||||
@transport.event_handler("on_client_disconnected")
|
||||
async def on_client_disconnected(_transport, _client):
|
||||
logger.info("Realtime 对端断开,结束管线")
|
||||
await worker.queue_frame(EndFrame())
|
||||
logger.info("Realtime 对端断开,立即取消管线")
|
||||
await worker.queue_frame(CancelFrame(reason="client_disconnected"))
|
||||
|
||||
Reference in New Issue
Block a user