소스 검색

fix(module): Deal with websocket disconnect #518

ryland 2 년 전
부모
커밋
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)