From c84ba48dd64cb04ce16d171cdeadc6d13a77e6c4 Mon Sep 17 00:00:00 2001 From: Abhinav Date: Thu, 11 Jun 2026 18:08:35 +0530 Subject: [PATCH] fix: don't block the event loop with time.sleep in async load_checkpoint (#6135) The export route's load_checkpoint waits for the training subprocess to exit by calling time.sleep(0.5) in a loop (up to 30s) inside an async function. time.sleep blocks the whole event loop, so every other request to the server stalls for that duration. Use await asyncio.sleep(0.5), matching the async pattern already used elsewhere in this file (asyncio.to_thread, await asyncio.sleep). Co-authored-by: Wasim Yousef Said --- studio/backend/routes/export.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/studio/backend/routes/export.py b/studio/backend/routes/export.py index abb89a13da..ef37daa158 100644 --- a/studio/backend/routes/export.py +++ b/studio/backend/routes/export.py @@ -78,8 +78,7 @@ async def load_checkpoint( for _ in range(60): # up to 30s if not trn.is_training_active(): break - import time - time.sleep(0.5) + await asyncio.sleep(0.5) else: logger.warning("Training subprocess did not exit within 30s, proceeding anyway") except Exception as e: