Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions demo/web/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,11 @@ async def flush_logs() -> None:
print("Client disconnected (WebSocketDisconnect)")
enqueue_log("client_disconnected")
stop_signal.set()
except Exception as e:
print(f"Error in websocket stream: {e}")
traceback.print_exc()
enqueue_log("backend_error", message=str(e))
stop_signal.set()
finally:
stop_signal.set()
enqueue_log("backend_stream_complete")
Expand All @@ -483,8 +488,11 @@ async def flush_logs() -> None:
log_queue.get_nowait()
except Empty:
break
if ws.client_state == WebSocketState.CONNECTED:
await ws.close()
try:
if ws.client_state == WebSocketState.CONNECTED:
await ws.close()
except Exception as e:
print(f"Error closing websocket: {e}")
print("WS handler exit")
finally:
if acquired:
Expand Down