Просмотр исходного кода

fix(module): Deal with websocket disconnect #518

ryland 2 лет назад
Родитель
Сommit
c88465eaca
1 измененных файлов с 5 добавлено и 1 удалено
  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):
         # 广播日志
         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)