fierce-jordan-44682
09/11/2025, 7:53 AMtall-airline-16756
09/11/2025, 7:53 AMtall-airline-16756
09/11/2025, 7:53 AMadd_shutdown_callback
function is meant to run during a controlled shutdown process, usually after the entrypoint function finishes. However, it’s important to note that it’s not clearly guaranteed these callbacks will run if the entrypoint encounters an unhandled exception.
To help make sure your cleanup tasks always get executed—even when exceptions happen—you might want to wrap your entrypoint logic in a try/finally
block. Then, you can place the necessary cleanup code inside the finally
section. This approach gives you a bit more peace of mind that everything will be handled properly.
Sources: examples/voice_agents/basic_agent.py | Inside a session | LiveKit Docs | Job lifecycle | LiveKit Docs | Session recording and transcripts | LiveKit Docs | main.pytall-airline-16756
09/11/2025, 7:53 AMadd_shutdown_callback
function is meant to run during a controlled shutdown process, usually after the entrypoint function finishes. That said, it's not completely clear if these callbacks will still run if the entrypoint encounters an unhandled exception.
To make sure your cleanup tasks are reliably executed—even when exceptions happen—a good approach is to wrap your entrypoint logic in a try/finally
block and place the necessary cleanup code inside the finally
section. This way, you can feel confident that your cleanup will always be taken care of.