Working docker-compose.yaml added. Services start and work.
This commit is contained in:
@@ -5,7 +5,7 @@ from typing import Dict, Set
|
||||
|
||||
from fastapi import WebSocket
|
||||
|
||||
# This will be set by main.py when the app starts
|
||||
# This will be set by main.py during startup
|
||||
MAIN_LOOP = None
|
||||
|
||||
active_connections: Dict[str, Set[WebSocket]] = {}
|
||||
@@ -29,13 +29,19 @@ def publish_progress(task_id: str, progress: int, message: str, status: str = "p
|
||||
}
|
||||
|
||||
to_remove = set()
|
||||
# Get the loop to use: either the stored one or try to get the current loop
|
||||
loop = MAIN_LOOP
|
||||
if loop is None:
|
||||
try:
|
||||
loop = asyncio.get_running_loop()
|
||||
except RuntimeError:
|
||||
# No running loop, fallback to default event loop
|
||||
loop = asyncio.get_event_loop()
|
||||
|
||||
for websocket in active_connections.get(task_id, set()):
|
||||
try:
|
||||
# Use the stored main loop, or fallback to getting the current loop
|
||||
loop = MAIN_LOOP or asyncio.get_running_loop()
|
||||
asyncio.run_coroutine_threadsafe(websocket.send_json(data), loop)
|
||||
except Exception:
|
||||
# Client disconnected or other error
|
||||
to_remove.add(websocket)
|
||||
|
||||
# Clean up disconnected clients
|
||||
|
||||
Reference in New Issue
Block a user