Repository navigation
fix(server): keep Git inspection off the event loop - #2103
RaghavChamadiya merged 1 commit into
Conversation
|
Root cause addressed as a complete blocking boundary: state-file reads, |
|
Rebased onto current |
b847f07 to
b322344
Compare
RaghavChamadiya
left a comment
There was a problem hiding this comment.
Thanks @justonemorenight. The thing that makes this the right version of the change is that you moved a whole unit rather than the one obvious call: _plan_incremental_page_regen keeps the git rev-parse, the GitPython-backed ChangeDetector, the pagerank ranking and the parsed-file filtering together in the worker thread, and leaves the DB stale-page lookup on the loop where it belongs. Offloading only the subprocess would have left get_affected_pages blocking, which is the expensive half on a large graph.
Reusing _read_head_sha and _load_state instead of re-inlining subprocess.run and json.loads is worth noting too. It picks up the exception handling those already have.
Both tests assert on the to_thread call itself, so they will fail if someone later inlines it back. Green on the full matrix, merging.
Summary
Root cause
APScheduler coroutine jobs and server job coroutines were invoking filesystem reads,
git rev-parse, andChangeDetectorsynchronously on the asyncio event loop. Moving onlyrev-parsewould leave GitPython change detection blocking, so the complete inspection/planning units now run through the existingasyncio.to_threadpattern.Validation
uv run ruff check ...uv run pytest tests/unit/server/test_scheduler.py tests/unit/server/test_job_executor.py -q(26 passed)Fixes #832