Spaces:
Running
Running
Pulastya B commited on
Commit ·
408337e
1
Parent(s): 6222009
ADD: Logging to trace SSE event streaming to client
Browse files- src/api/app.py +2 -0
- src/progress_manager.py +1 -0
src/api/app.py
CHANGED
|
@@ -202,6 +202,7 @@ async def stream_progress(session_id: str):
|
|
| 202 |
'message': '🔗 Connected to progress stream',
|
| 203 |
'session_id': session_id
|
| 204 |
}
|
|
|
|
| 205 |
yield f"data: {json.dumps(connection_event)}\n\n"
|
| 206 |
|
| 207 |
# Send any existing history first (for reconnections)
|
|
@@ -211,6 +212,7 @@ async def stream_progress(session_id: str):
|
|
| 211 |
|
| 212 |
# Stream new events as they occur
|
| 213 |
async for event in progress_manager.subscribe(session_id):
|
|
|
|
| 214 |
yield f"data: {json.dumps(event)}\n\n"
|
| 215 |
|
| 216 |
# Check if analysis is complete
|
|
|
|
| 202 |
'message': '🔗 Connected to progress stream',
|
| 203 |
'session_id': session_id
|
| 204 |
}
|
| 205 |
+
print(f"[SSE] SENDING connection event to client")
|
| 206 |
yield f"data: {json.dumps(connection_event)}\n\n"
|
| 207 |
|
| 208 |
# Send any existing history first (for reconnections)
|
|
|
|
| 212 |
|
| 213 |
# Stream new events as they occur
|
| 214 |
async for event in progress_manager.subscribe(session_id):
|
| 215 |
+
print(f"[SSE] STREAMING event to client: {event.get('type')}")
|
| 216 |
yield f"data: {json.dumps(event)}\n\n"
|
| 217 |
|
| 218 |
# Check if analysis is complete
|
src/progress_manager.py
CHANGED
|
@@ -84,6 +84,7 @@ class ProgressManager:
|
|
| 84 |
try:
|
| 85 |
while True:
|
| 86 |
event = await queue.get()
|
|
|
|
| 87 |
yield event
|
| 88 |
except asyncio.CancelledError:
|
| 89 |
# Client disconnected
|
|
|
|
| 84 |
try:
|
| 85 |
while True:
|
| 86 |
event = await queue.get()
|
| 87 |
+
print(f"[SSE] YIELDING event to client: type={event.get('type')}, msg={event.get('message', '')[:50]}")
|
| 88 |
yield event
|
| 89 |
except asyncio.CancelledError:
|
| 90 |
# Client disconnected
|