We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e3e2a5c commit 03ff67eCopy full SHA for 03ff67e
1 file changed
src/server/main/chat/routes.py
@@ -55,9 +55,8 @@ async def event_stream_generator():
55
if not event:
56
continue
57
# yield as bytes and flush
58
- chunk = (json.dumps(event) + "\n").encode("utf-8")
59
- yield chunk
60
- await asyncio.sleep(1) # Force control back to event loop
+ yield json.dumps(event) + "\n"
+ await asyncio.sleep(0.1) # Yield control to the event loop
61
except asyncio.CancelledError:
62
logger.info(f"Client disconnected, stream cancelled for user {user_id}.")
63
except Exception as e:
0 commit comments