From f55e55e50d42c860b67bde6f0e114f2914bdf9be Mon Sep 17 00:00:00 2001 From: Blasius Patrick Date: Tue, 11 Aug 2026 13:54:45 +0700 Subject: [PATCH] =?UTF-8?q?fix:=20non-blocking=20chunk=20I/O=20=E2=80=94?= =?UTF-8?q?=20use=20run=5Fin=5Fexecutor=20for=20file=20writes=20to=20preve?= =?UTF-8?q?nt=20event=20loop=20stall=20(#116)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Blasius Patrick --- wsserver/server.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/wsserver/server.py b/wsserver/server.py index 23621de..b7c9696 100644 --- a/wsserver/server.py +++ b/wsserver/server.py @@ -356,10 +356,11 @@ async def _handle_exec_chunk( ) await registry.set_chunk_state(node_name, request_id, cs) - # -- Append data to the temp file ------------------------------------ + # -- Append data to the temp file (non-blocking — disk I/O in executor) - + loop = asyncio.get_running_loop() try: - cs.file.write(chunk_bytes) - cs.file.flush() + await loop.run_in_executor(None, cs.file.write, chunk_bytes) + await loop.run_in_executor(None, cs.file.flush) except Exception: logger.warning( "exec_chunk from %r id=%r write to temp file failed",