From c93ec2792dbb6c8904449ed7ab27d69c27d46284 Mon Sep 17 00:00:00 2001 From: Google AI Studio Date: Thu, 19 Mar 2026 21:55:57 -0400 Subject: [PATCH] Review Fix: Improve src/infrastructure/ws_manager/handler.py --- src/infrastructure/ws_manager/handler.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/infrastructure/ws_manager/handler.py b/src/infrastructure/ws_manager/handler.py index 978a195..9df3717 100644 --- a/src/infrastructure/ws_manager/handler.py +++ b/src/infrastructure/ws_manager/handler.py @@ -79,7 +79,17 @@ class WebSocketManager: message = ws_event.to_json() disconnected = [] - for ws in self._connections: + import asyncio + tasks = [ws.send_text(message) for ws in self._connections] + results = await asyncio.gather(*tasks, return_exceptions=True) + + disconnected = [] + for ws, result in zip(self._connections, results): + if isinstance(result, Exception): + logger.warning(f"WebSocket send error: {result}") + disconnected.append(ws) + + # Skip the old loop try: await ws.send_text(message) except ConnectionError: