abundant-father-33863
10/02/2025, 5:30 AMtall-airline-16756
10/02/2025, 5:30 AMtall-airline-16756
10/02/2025, 5:30 AMadd_shutdown_callback in LiveKit. The callback function can optionally take a single argument, which will be the shutdown reason—pretty handy, right?
Here’s a simple example in Python to illustrate:
async def _on_shutdown(reason: str):
# `reason` contains the shutdown reason
print(f"Shutting down because: {reason}")
ctx.add_shutdown_callback(_on_shutdown)
So, in this example, the reason parameter will hold the shutdown reason whenever the callback runs. If you need any more help with this, feel free to ask—I’m here to help!
Sources: livekit-agents/livekit/agents/ipc/job_proc_lazy_main.py