Fix asyncio scoping in frontend websocket
Browse files
frontend/react_gradio_hybrid.py
CHANGED
|
@@ -464,7 +464,6 @@ async def frontend_websocket(websocket: WebSocket, conversation_id: str):
|
|
| 464 |
})
|
| 465 |
|
| 466 |
# Start forwarding messages from backend to frontend
|
| 467 |
-
import asyncio
|
| 468 |
asyncio.create_task(forward_backend_messages(conversation_id))
|
| 469 |
else:
|
| 470 |
await websocket.send_json({
|
|
@@ -501,8 +500,6 @@ async def frontend_websocket(websocket: WebSocket, conversation_id: str):
|
|
| 501 |
|
| 502 |
async def forward_backend_messages(conversation_id: str):
|
| 503 |
"""Forward messages from backend WebSocket manager to frontend."""
|
| 504 |
-
import asyncio
|
| 505 |
-
|
| 506 |
manager = active_managers.get(conversation_id)
|
| 507 |
frontend_ws = frontend_connections.get(conversation_id)
|
| 508 |
|
|
|
|
| 464 |
})
|
| 465 |
|
| 466 |
# Start forwarding messages from backend to frontend
|
|
|
|
| 467 |
asyncio.create_task(forward_backend_messages(conversation_id))
|
| 468 |
else:
|
| 469 |
await websocket.send_json({
|
|
|
|
| 500 |
|
| 501 |
async def forward_backend_messages(conversation_id: str):
|
| 502 |
"""Forward messages from backend WebSocket manager to frontend."""
|
|
|
|
|
|
|
| 503 |
manager = active_managers.get(conversation_id)
|
| 504 |
frontend_ws = frontend_connections.get(conversation_id)
|
| 505 |
|