Skip to content

fix: wait between /readyz polls when the server answers with a non-200 status - #1250

Open
pcbeingused333 wants to merge 1 commit into
bentoml:mainfrom
pcbeingused333:c0496-readyz-sleep
Open

pcbeingused333 wants to merge 1 commit into
bentoml:mainfrom
pcbeingused333:c0496-readyz-sleep

Conversation

@pcbeingused333

Copy link
Copy Markdown

Fixes the busy loop in openllm run while the model is loading.

Root cause. In _run_model (src/openllm/local.py) the await asyncio.sleep(1) between /readyz polls was indented inside except httpx.RequestError. When the server is up but answers /readyz with a non-200 status (for example 503 while the model loads), no exception is raised, the loop does not sleep and polls immediately. The for _ in range(timeout) budget (600 by default) is then used up in seconds, ending in "Model failed to load" long before timeout seconds have passed, and hammering the server meanwhile.

Fix. Dedent the sleep one level so every failed poll waits one second, whether the request errored or returned a non-200 status.

Test. tests/test_local_readyz.py runs _run_model with a simulated /readyz that always returns 503 and a recorded asyncio.sleep, and asserts one sleep per poll. It fails on main (0 sleeps) and passes with the change.

This change was prepared with the help of an AI coding assistant (Claude Code) and submitted by Alex Castillo González.

…0 status

The 1 second sleep in _run_model sat inside the except httpx.RequestError
branch, so a server that answered /readyz with 503 while loading was polled
in a tight loop and the timeout budget burned in a few seconds instead of
timeout seconds. Move the sleep after the try/except so every failed poll waits.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@pcbeingused333

Copy link
Copy Markdown
Author

Friendly ping: this is ready for review whenever someone has a moment. Happy to adjust anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant