From 96cd404f5fc27a7d6dec07cc18c73ba1293e7f88 Mon Sep 17 00:00:00 2001 From: James Ketrenos Date: Thu, 20 Mar 2025 17:58:33 -0700 Subject: [PATCH] Safe remove of items in exception --- jupyter/stock.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jupyter/stock.py b/jupyter/stock.py index 9f5aeaf..9d0ac65 100644 --- a/jupyter/stock.py +++ b/jupyter/stock.py @@ -771,7 +771,8 @@ class WebServer: if not session_id in self.sessions: self.generate_session(ws, session_id) - self.sessions[session_id]['sockets'].append(ws) + if ws not in self.sessions[session_id]['sockets']: + self.sessions[session_id]['sockets'].append(ws) while True: try: @@ -837,6 +838,7 @@ class WebServer: self.sessions[session_id]['sockets'].remove(ws) for socket in self.sessions[session_id]['sockets']: socket.send(json.dumps({"type": "users", "update": self.sessions[session_id]['users']})) + return # Serve React app - This catches all routes not matched by API endpoints @self.app.route('/')