Explorar el Código

fix(module): Deal with websocket disconnect #518

ryland hace 2 años
padre
commit
c88465eaca
Se han modificado 1 ficheros con 5 adiciones y 1 borrados
  1. 5 1
      module/server/script_websocket.py

+ 5 - 1
module/server/script_websocket.py

@@ -30,7 +30,11 @@ class ScriptWSManager:
     async def broadcast_log(self, log: str):
     async def broadcast_log(self, log: str):
         # 广播日志
         # 广播日志
         for connection in self.active_connections:
         for connection in self.active_connections:
-            await connection.send_text(log)
+            try:
+                await connection.send_text(log)
+            except RuntimeError as e:
+                print(e)
+                self.active_connections.remove(connection)