MikelWL commited on
Commit
b54dbda
·
1 Parent(s): f149435

Fix WS deadlock: start WebSocketManager in thread

Browse files
Files changed (1) hide show
  1. frontend/react_gradio_hybrid.py +3 -2
frontend/react_gradio_hybrid.py CHANGED
@@ -2,6 +2,7 @@ import sys
2
  import json
3
  import time
4
  import os
 
5
  from pathlib import Path
6
  from typing import Dict, List
7
  import logging
@@ -449,7 +450,7 @@ async def frontend_websocket(websocket: WebSocket, conversation_id: str):
449
 
450
  if message_type == "start_conversation":
451
  # Start the backend WebSocket manager
452
- success = manager.start()
453
 
454
  if success:
455
  # Send start message to backend
@@ -478,7 +479,7 @@ async def frontend_websocket(websocket: WebSocket, conversation_id: str):
478
  "content": "stop",
479
  "action": "stop"
480
  })
481
- manager.stop()
482
 
483
  await websocket.send_json({
484
  "type": "conversation_status",
 
2
  import json
3
  import time
4
  import os
5
+ import asyncio
6
  from pathlib import Path
7
  from typing import Dict, List
8
  import logging
 
450
 
451
  if message_type == "start_conversation":
452
  # Start the backend WebSocket manager
453
+ success = await asyncio.to_thread(manager.start)
454
 
455
  if success:
456
  # Send start message to backend
 
479
  "content": "stop",
480
  "action": "stop"
481
  })
482
+ await asyncio.to_thread(manager.stop)
483
 
484
  await websocket.send_json({
485
  "type": "conversation_status",