From 2f0d8bbd8c4de43fe26e0f2edcd05aef3c8c71f9 Mon Sep 17 00:00:00 2001 From: Miguel Grinberg Date: Sat, 22 May 2021 15:04:27 +0100 Subject: [PATCH] more robust handling of emit's "to" argument (Fixes #689) --- socketio/base_manager.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/socketio/base_manager.py b/socketio/base_manager.py index f50cd720..49e9e98c 100644 --- a/socketio/base_manager.py +++ b/socketio/base_manager.py @@ -39,12 +39,12 @@ def get_namespaces(self): def get_participants(self, namespace, room): """Return an iterable with the active participants in a room.""" ns = self.rooms[namespace] - if room is None or isinstance(room, str): - participants = ns[room]._fwdm.copy() if room in ns else {} - else: + if hasattr(room, '__len__') and not isinstance(room, str): participants = ns[room[0]]._fwdm.copy() if room[0] in ns else {} for r in room[1:]: participants.update(ns[r]._fwdm if r in ns else {}) + else: + participants = ns[room]._fwdm.copy() if room in ns else {} for sid, eio_sid in participants.items(): yield sid, eio_sid