From 8e2c99e3cf3b85390ff9aa47edb7cbd319dfdc3b Mon Sep 17 00:00:00 2001 From: comfyanonymous Date: Tue, 2 Jan 2024 11:50:00 -0500 Subject: [PATCH] Fix issue when websocket is deleted when data is being sent. --- server.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server.py b/server.py index 9b1e3269..bd6f026b 100644 --- a/server.py +++ b/server.py @@ -584,7 +584,8 @@ class PromptServer(): message = self.encode_bytes(event, data) if sid is None: - for ws in self.sockets.values(): + sockets = list(self.sockets.values()) + for ws in sockets: await send_socket_catch_exception(ws.send_bytes, message) elif sid in self.sockets: await send_socket_catch_exception(self.sockets[sid].send_bytes, message) @@ -593,7 +594,8 @@ class PromptServer(): message = {"type": event, "data": data} if sid is None: - for ws in self.sockets.values(): + sockets = list(self.sockets.values()) + for ws in sockets: await send_socket_catch_exception(ws.send_json, message) elif sid in self.sockets: await send_socket_catch_exception(self.sockets[sid].send_json, message)