SurfSense/surfsense_backend/app/utils/file_io.py
Sanjay Santhanam 5cc05d90f0 fix: avoid blocking audio writes
TTS responses were written synchronously from the async presentation pipeline, blocking concurrent requests. Offload byte writes to a worker thread and add a regression test that keeps the event loop responsive.
2026-07-18 17:46:31 -07:00

7 lines
216 B
Python

import asyncio
from pathlib import Path
async def write_bytes(path: str, content: bytes) -> None:
"""Write bytes without blocking the event loop."""
await asyncio.to_thread(Path(path).write_bytes, content)