Skip to content

Keep the vision warmup off the dashboard's event loop - #446

Merged
AVADSA25 merged 1 commit into
mainfrom
startup-no-block
Oct 7, 2026
Merged

AVADSA25 merged 1 commit into
mainfrom
startup-no-block

Conversation

@AVADSA25

@AVADSA25 AVADSA25 commented Oct 7, 2026

Copy link
Copy Markdown
Owner

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() is async but called requests.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".
  • ruff clean.

Deploy

Restart codec-dashboard.

🤖 Generated with Claude Code

_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>
@AVADSA25
AVADSA25 merged commit 1547862 into main Oct 7, 2026
1 check passed
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.

2 participants