Skip to content

Commit ed188b9

Browse files
committed
fix: unsubscribe FFI queue when the room listen task ends
1 parent 639682f commit ed188b9

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

livekit-rtc/livekit/rtc/room.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,14 @@ def on_participant_connected(participant):
557557
# start listening to room events
558558
self._task = self._loop.create_task(self._listen_task())
559559

560+
# unsubscribe from the FFI queue once the listen task ends.
561+
# disconnect() unsubscribes too, but it early-returns when the
562+
# room is already disconnected (e.g. removed remotely).
563+
ffi_queue = self._ffi_queue
564+
self._task.add_done_callback(
565+
lambda _: FfiClient.instance.queue.unsubscribe(ffi_queue)
566+
)
567+
560568
# Unblock the FFI server once this SDK is ready to receive room events.
561569
ready_req = proto_ffi.FfiRequest()
562570
ready_req.ready_for_room_event.room_handle = self._ffi_handle.handle

0 commit comments

Comments
 (0)