From e984e703904620bddfa269572907b8d0927607ff Mon Sep 17 00:00:00 2001 From: "Radu C. Martin" Date: Tue, 15 Apr 2025 14:11:12 +0200 Subject: [PATCH] fix: make a copy of websockets before broadcasting --- main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 33ea8b3..763554b 100644 --- a/main.py +++ b/main.py @@ -40,7 +40,9 @@ class ConnectionManager: async def broadcast(self, ws_type: WSConnectionType, message: BaseModel): broken = set() - for ws in self.active_connections[ws_type.value]: + conn_list = list(self.active_connections[ws_type.value]) + for idx in range(len(conn_list)): + ws = conn_list[idx] try: await ws.send_json(message.model_dump()) except Exception: