Skip to content

Commit 03ff67e

Browse files
committed
fix (chat): resolving buffering issues (WIP)
1 parent e3e2a5c commit 03ff67e

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

src/server/main/chat/routes.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,8 @@ async def event_stream_generator():
5555
if not event:
5656
continue
5757
# 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
58+
yield json.dumps(event) + "\n"
59+
await asyncio.sleep(0.1) # Yield control to the event loop
6160
except asyncio.CancelledError:
6261
logger.info(f"Client disconnected, stream cancelled for user {user_id}.")
6362
except Exception as e:

0 commit comments

Comments
 (0)