fix(dashboard): offload cron profile scans - #45491
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR moves cron dashboard operations (profile scanning and job I/O) off the FastAPI event loop by running them in a background thread, and adds a regression test to verify the offloading behavior.
Changes:
- Refactors cron dashboard endpoints to delegate to sync helpers executed via a thread offload wrapper.
- Introduces
_run_cron_dashboard_io()and sync variants of the cron endpoints’ core logic. - Adds a test ensuring profile scanning and profile resolution do not run on the event-loop thread.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
hermes_cli/web_server.py |
Offloads cron dashboard I/O to a worker thread via a shared wrapper and sync helpers. |
tests/hermes_cli/test_web_server_cron_profiles.py |
Adds a regression test to assert cron profile scanning happens off the event loop. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Verification: clean review — no issues found. Reviewed the diff (132 additions across
Approach is sound — offloading blocking cron I/O to the threadpool prevents event loop stalls when the dashboard polls cron profiles across multiple Hermes profiles. |
…load # Conflicts: # hermes_cli/web_server.py # tests/hermes_cli/test_web_server_cron_profiles.py
What does this PR do?
Moves the dashboard cron job endpoints' profile and job file work out of the FastAPI event loop.
Before this change, endpoints like
GET /api/cron/jobs?profile=allscanned profiles and read cron job files directly insideasync defhandlers. With many profiles, that synchronous work could block the backend event loop and delay unrelated HTTP or WebSocket traffic during desktop startup.This PR keeps the same API behavior and response shapes, but runs the cron dashboard work in a worker thread with
asyncio.to_thread().Related Issue
Fixes #45072
Type of Change
Changes Made
hermes_cli/web_server.py.profile=allprofile scanning and no-profile job lookup run outside the event-loop thread.How to Test
I also ran
git diff --check.Note: I tried a focused
ruff check, but the shared local venv used by this checkout does not haveruffinstalled.Checklist
Screenshots / Logs
N/A - backend-only change.