Repository navigation
Keep the vision warmup off the dashboard's event loop - #446
Merged
Merged
Conversation
_warmup_vision() ran requests.post(..., timeout=60) on the event loop 5 s after startup, so while the local model was stuck no page or API call was answered until the timeout (6 Oct: startup 23:25:31, warmup gave up 23:26:36; the dashboard took 90-129 s to answer after restarts). _vision_keepalive() did the same every 10 minutes for up to 10 s. Both now run the request in a thread. Logged: three photo routes have the same blocking pattern. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
After a restart the dashboard took 90-129 s to answer while the local model was stuck (Mac merge pass, docs/known-issues.md). Cause:
_warmup_vision()isasyncbut calledrequests.post(..., timeout=60)directly on the event loop 5 s after startup, so nothing else ran until the model answered or the timeout passed. The log of the slow #430 restart shows it: startup 23:25:31, "Vision warmup failed" 23:26:36._vision_keepalive()did the same every 10 minutes (up to 10 s).Both requests now run with
asyncio.to_thread. The warmup delay is a module constant so the test can skip it.Also found (logged, not changed): three photo routes (
webcam_capture,upload_image,vision_analyze) call the vision model the same blocking way, so the dashboard pauses while a picture is analysed.Checks
tests/test_startup_not_blocked.py: with a 0.6 s fake model, the event loop never stalls more than 0.3 s during the warmup; the keep-alive uses a thread. Negative control (only the thread change reverted): "the loop stalled for 0.60 s".Deploy
Restart
codec-dashboard.🤖 Generated with Claude Code