Skip to content

Commit e243b61

Browse files
committed
fix(rtc): shield orphaned room cleanup with state reset in finally and remove cleanup timeout
1 parent f110eef commit e243b61

2 files changed

Lines changed: 12 additions & 13 deletions

File tree

‎livekit-rtc/livekit/rtc/room.py‎

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -647,13 +647,15 @@ def on_participant_connected(participant):
647647
if not ready_sent:
648648
if self._task is not None and not self._task.done():
649649
self._task.cancel()
650-
await self._cleanup_orphaned_room(self._ffi_handle)
651-
self._ffi_handle = None
652-
self._connection_state = ConnectionState.CONN_DISCONNECTED
653-
self._remote_participants.clear()
654-
self._local_participant = None
655-
self._info = proto_room.RoomInfo()
656-
self._fail_sid_waiters(e)
650+
try:
651+
await asyncio.shield(self._cleanup_orphaned_room(self._ffi_handle))
652+
finally:
653+
self._ffi_handle = None
654+
self._connection_state = ConnectionState.CONN_DISCONNECTED
655+
self._remote_participants.clear()
656+
self._local_participant = None
657+
self._info = proto_room.RoomInfo()
658+
self._fail_sid_waiters(e)
657659
raise
658660

659661
@staticmethod
@@ -664,11 +666,8 @@ async def _cleanup_cancelled_connect(
664666
) -> None:
665667
try:
666668
try:
667-
cb = await asyncio.wait_for(
668-
queue.wait_for(lambda e: e.connect.async_id == async_id),
669-
timeout=30.0,
670-
)
671-
except (asyncio.TimeoutError, asyncio.CancelledError):
669+
cb = await queue.wait_for(lambda e: e.connect.async_id == async_id)
670+
except asyncio.CancelledError:
672671
return
673672

674673
if not cb.connect.error and cb.connect.result.room.handle.id != 0:

‎livekit-rtc/tests/test_ffi_client.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
2828
gc.collect()
2929
gc.set_debug(gc.DEBUG_SAVEALL)
30-
for _ in range(50):
30+
for _ in range(10):
3131
rtc.AudioProcessingModule()
3232
gc.collect()
3333
print(sum(isinstance(o, type(ctypes.Array)) for o in gc.garbage))

0 commit comments

Comments
 (0)