Description
The RecordWriter.write_request call in src/reflex/runtime/server.py (line 2428) is a synchronous, blocking I/O operation called inside an async def handler.
Rationale
Writing large JSONL lines (containing MBs of image base64) and calling flush() synchronously freezes the asyncio event loop. This blocks all concurrent requests and introduces 50-100ms of jitter into the 100Hz robot control loop.
Tasks
Description
The
RecordWriter.write_requestcall insrc/reflex/runtime/server.py(line 2428) is a synchronous, blocking I/O operation called inside anasync defhandler.Rationale
Writing large JSONL lines (containing MBs of image base64) and calling
flush()synchronously freezes theasyncioevent loop. This blocks all concurrent requests and introduces 50-100ms of jitter into the 100Hz robot control loop.Tasks
RecordWriterto use an internalqueue.Queueand a background worker thread.loop.run_in_executoror a non-blocking queue push in the/acthandler.