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:
parent
ab9689c034
commit
c84ba48dd6
1 changed files with 1 additions and 2 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue