cool-lizard-26153
12/17/2025, 12:14 PMTask exception was never retrieved
future: <Task finished name='agent_job_termination' coro=<AgentServer._handle_termination() done, defined at /usr/local/lib/python3.10/site-packages/livekit/agents/worker.py:1256> exception=ValueError('process object is closed')>", "exc_info": "Traceback (most recent call last):
File \"/usr/local/lib/python3.10/asyncio/tasks.py\", line 456, in wait_for
return fut.result()
asyncio.exceptions.CancelledError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File \"/usr/local/lib/python3.10/site-packages/livekit/agents/ipc/supervised_proc.py\", line 252, in aclose
await asyncio.wait_for(
File \"/usr/local/lib/python3.10/asyncio/tasks.py\", line 458, in wait_for
raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File \"/usr/local/lib/python3.10/site-packages/livekit/agents/worker.py\", line 1261, in _handle_termination
await proc.aclose()
File \"/usr/local/lib/python3.10/site-packages/livekit/agents/ipc/supervised_proc.py\", line 261, in aclose
await self._send_kill_signal()
File \"/usr/local/lib/python3.10/site-packages/livekit/agents/ipc/supervised_proc.py\", line 317, in _send_kill_signal
self._proc.kill()
File \"/usr/local/lib/python3.10/multiprocessing/process.py\", line 139, in kill
self._check_closed()
File \"/usr/local/lib/python3.10/multiprocessing/process.py\", line 101, in _check_closed
raise ValueError(\"process object is closed\")
ValueError: process object is closed
what is happening here?tall-airline-16756
12/17/2025, 12:14 PMtall-airline-16756
12/17/2025, 12:14 PMproc.aclose().
• Inside that shutdown path it attempts self._proc.kill().
• If the worker process already exited or was cleaned up earlier, calling .kill() raises ValueError: process object is closed. This is a race condition during cleanup, not an indication that the job still running.
What you can do
• Increase the agent drain_timeout so workers have more time to exit cleanly before forced shutdown.
• Upgrade to the latest LiveKit Python SDK (the shutdown/process lifecycle has improvements that reduce this race).
• If this exception is only logged and doesn’t affect behavior, you can treat it as a cleanup artifact; otherwise add a small guard around the kill path to ignore ValueError during shutdown.
If you’d like, tell me:
• which SDK version you upgraded from/to, and
• your current drain_timeout (or agent shutdown config)
and I’ll suggest the next concrete step.
Sources: Still Have Questions | Agent server options | LiveKit docs | Deploying to custom environments | LiveKit docs | Job lifecycle | LiveKit docscool-lizard-26153
12/17/2025, 12:23 PMtall-airline-16756
12/17/2025, 12:23 PM.kill() on that closed multiprocessing.Process.
• A race during graceful termination: shutdown begins while workers are still finishing, so cleanup and a forced kill overlap.
• A short drain_timeout or aggressive shutdown signal that causes the agent to try killing processes that have already been cleaned up.
• A change in SDK shutdown behavior after an upgrade that exposes this timing window more often.
Because this is an internal cleanup race, you won't see a reference to your application code in the traceback.
To help pinpoint why it happened in your deployment:
• Which LiveKit Python SDK version did you upgrade from and to?
• Do you use custom job worker code or the standard job lifecycle?
• What is your agent's drain_timeout (or shutdown/drain configuration)?
• Did you see any worker crashes or other errors just before this traceback?
Give me those details and I’ll suggest the most relevant next step.