mirror of
https://github.com/azaion/detections.git
synced 2026-06-21 17:31:08 +00:00
Fixed prevent smoke builds and keep SSE streams alive
This commit is contained in:
+5
-2
@@ -415,8 +415,11 @@ async def detect_events(channel_id: str, request: Request, after_ts: Optional[in
|
||||
if ts_ms > after_ts:
|
||||
yield f"id: {ts_ms}\ndata: {data}\n\n"
|
||||
while True:
|
||||
ts_ms, data = await queue.get()
|
||||
yield f"id: {ts_ms}\ndata: {data}\n\n"
|
||||
try:
|
||||
ts_ms, data = await asyncio.wait_for(queue.get(), timeout=1.0)
|
||||
yield f"id: {ts_ms}\ndata: {data}\n\n"
|
||||
except asyncio.TimeoutError:
|
||||
yield ": heartbeat\n\n"
|
||||
except asyncio.CancelledError:
|
||||
pass
|
||||
finally:
|
||||
|
||||
Reference in New Issue
Block a user