clever-apartment-50437
10/08/2025, 9:36 PMtall-airline-16756
10/08/2025, 9:37 PMtall-airline-16756
10/08/2025, 9:37 PMJobContext object doesn’t have a wait_for_disconnect method. No worries though! To handle disconnection in LiveKit, here’s a friendly approach you can try:
Event-based Waiting:
disconnect_event = asyncio.Event()
@context.room.on("disconnected")
def on_room_disconnect(*args):
disconnect_event.set()
# Wait until the room is disconnected
await disconnect_event.wait()
This way, you’re listening for the "disconnected" event on the room object, and your code will wait until that event happens.
Also, if you’re looking to wait for the room to empty rather than disconnect, you can watch for "participant_disconnected" events and keep an eye on the participant count. Feel free to reach out if you’d like a hand putting this together—I’m here to help!
Sources: examples/voice_agents/realtime_joke_teller.py | sip-refer/README.mdoc | agent.py | Job lifecycle | LiveKit Docs