You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the Livekit Server terminates a room and removes a Python client, the task responsible for listening (self._listen_task) does not properly conclude or cancel.
Background
We have set up a Python participant to join a specific room and listen to a particular track. If the track is no longer published, the Python participant leaves the room, completes all asynchronous tasks, and then the process exits. However, if the room is deleted, the Python participant struggles to disconnect and the _listen_task remains active.
Diagnostics
The Room.disconnect() method is designed to clear the task queue and wait for self._task to finish. But, if the Livekit Server deletes the room, the Room.disconnect() cannot complete as it fails the self.isconnected() check, resulting in self._task remaining in a running state.
We suggest introducing an aclose() function to manage disconnections and clean up any remaining asynchronous tasks. Currently, we have implemented the following in the object that utilizes the Room object:
asyncdefaclose(self):
ifself.is_closed():
returntry:
fortaskinself._tasks:
task.cancel()
awaitasyncio.gather(*self._tasks, return_exceptions=True)
awaitself._room.disconnect()
exceptExceptionaserr:
logger.error(f"Error shutting down transcript agent: {str(err)}")
finally:
ifself._room._task:
self._room._task.cancel()
logger.warning("Room disconnect method failed to close _listen_task")
self._closed=True
The text was updated successfully, but these errors were encountered:
The correct implementation would be to always call self._room.disconnect like you do, the difference is that we're now awaiting the main task in #200. There is no need to cancel the task because the Rust SDK should send EOS which will break the infinite loop
Issue Description
Overview
When the Livekit Server terminates a room and removes a Python client, the task responsible for listening (
self._listen_task
) does not properly conclude or cancel.Background
We have set up a Python participant to join a specific room and listen to a particular track. If the track is no longer published, the Python participant leaves the room, completes all asynchronous tasks, and then the process exits. However, if the room is deleted, the Python participant struggles to disconnect and the
_listen_task
remains active.Diagnostics
The
Room.disconnect()
method is designed to clear the task queue and wait forself._task
to finish. But, if the Livekit Server deletes the room, theRoom.disconnect()
cannot complete as it fails theself.isconnected()
check, resulting inself._task
remaining in a running state.View the code segment here: Room.py Line 221
Requested Solution
We suggest introducing an
aclose()
function to manage disconnections and clean up any remaining asynchronous tasks. Currently, we have implemented the following in the object that utilizes the Room object:The text was updated successfully, but these errors were encountered: