From 2ff249378212ba578d50cc136998a8a52185447d Mon Sep 17 00:00:00 2001 From: martin-purplefish Date: Fri, 1 Nov 2024 13:35:42 -0400 Subject: [PATCH] Fix stack dump on shutdown (#1023) --- .changeset/heavy-turtles-rule.md | 5 +++++ livekit-agents/livekit/agents/ipc/job_main.py | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .changeset/heavy-turtles-rule.md diff --git a/.changeset/heavy-turtles-rule.md b/.changeset/heavy-turtles-rule.md new file mode 100644 index 000000000..20fbae71d --- /dev/null +++ b/.changeset/heavy-turtles-rule.md @@ -0,0 +1,5 @@ +--- +"livekit-agents": patch +--- + +Fix stack dump on closed stream diff --git a/livekit-agents/livekit/agents/ipc/job_main.py b/livekit-agents/livekit/agents/ipc/job_main.py index 8668ffe92..4e7519400 100644 --- a/livekit-agents/livekit/agents/ipc/job_main.py +++ b/livekit-agents/livekit/agents/ipc/job_main.py @@ -208,7 +208,11 @@ async def _async_main( async def _read_ipc_task(): nonlocal job_task while True: - msg = await channel.arecv_message(cch, proto.IPC_MESSAGES) + try: + msg = await channel.arecv_message(cch, proto.IPC_MESSAGES) + except duplex_unix.DuplexClosed: + break + with contextlib.suppress(utils.aio.SleepFinished): no_msg_timeout.reset()