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 <wasimysdev@gmail.com>
This commit is contained in:
Abhinav 2026-06-11 18:08:35 +05:30 committed by GitHub
commit c84ba48dd6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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: