Skip to content

emrg: offload remaining sync git probes from event loop (rant 2026-08-19T01:05:47) - #859

Merged
argszero merged 1 commit into
masterfrom
feature/no-blocking-calls-event-loop
Aug 18, 2026
Merged

emrg: offload remaining sync git probes from event loop (rant 2026-08-19T01:05:47)#859
argszero merged 1 commit into
masterfrom
feature/no-blocking-calls-event-loop

Conversation

@argszero

Copy link
Copy Markdown
Owner

Summary

Systematic audit per host rant 2026-08-19T01:05:47: no blocking calls in the asyncio event loop. The scheduler clone blocking (fixed in #858) was one instance; this PR closes the remaining sync git probes that run in async serving contexts.

Audit findings (this PR's scope)

SiteContextFix
daemon.pyprojects_list handlerOn the event loop while serving websockets; ran _detect_git_remote (sync git remote get-url subprocess, 5s timeout) per project sequentiallyawait asyncio.to_thread(_detect_git_remote, ...) gathered in parallel
scheduler.pyapply_tasks (hot reload)On the event loop while serving; TaskHandler.__init__ runs _detect_git_remote (git subprocess) + resolve_git_gh (file IO + cache write)New _start_handler_asyncasyncio.to_thread(self._build_handler, cfg); create_task still on the loop
scheduler.py boot path_start_handler_for at daemon boot — no websocket clients connected yetKept sync (documented)

What was already compliant (verified, unchanged)

  • emrg/tools/ — bash tool already asyncio.create_subprocess_shell; no other blocking calls (grep/glob/read/write/edit are file IO on the loop, sub-ms)
  • emrg/connect.pyis_server_running_sync / socket.create_connection only called from client sync context and the daemon's pre-serve admission gate
  • emrg/server/scheduler.py workspace self-heal git calls — already offloaded via asyncio.to_thread (emrg: scheduler workspace-heal async offload + clone backoff (rant 2026-08-19T00:54:32) #858)
  • emrg/client/ — TUI process manager is a sync main loop, not an asyncio websocket server

Verification

  • New tests (pure static-source assertions + existing mock-based apply_tasks tests run directly):
    • test_hot_reload_offloads_handler_construction_to_thread — apply_tasks awaits _start_handler_async; construction via asyncio.to_thread; boot path stays sync
    • test_daemon_projects_list_offloads_git_probe_to_thread — daemon source uses asyncio.to_thread(_detect_git_remote, ...) gathered
    • test_apply_tasks_hot_reload / test_apply_tasks_update_restart / test_apply_tasks_idempotent — still pass (behavior preserved)
  • Import + CLI checks pass. Agent.md count 961 → 963 (2 new test functions).
  • Full CI (ubuntu + windows, actionlint + doc-count guard) validates.

@argszeroargszero left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle 790 (Committer). CI test + test-windows both PASS on head 56feb3e (doc-count guard validated 963). Offloads verified: daemon projects_list gather+to_thread, scheduler _start_handler_async; boot path intentionally stays sync (pre-serve).

@argszeroargszero left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle 791 (Committer). Independent re-verify: head unchanged (56feb3e), CI test + test-windows PASS. Diff re-inspected — daemon projects_list to_thread+gather, scheduler _start_handler_async offload; boot path stays sync pre-serve. 2/3.

@argszeroargszero left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle 792 (Committer). 3rd consecutive approval. Head unchanged (56feb3e), CI green, MERGEABLE. Merging.

@argszero
argszero merged commit dd7e6a1 into masterAug 18, 2026
2 checks passed
@argszero
argszero deleted the feature/no-blocking-calls-event-loop branch August 18, 2026 18:10
argszero added a commit that referenced this pull request Aug 19, 2026
Co-authored-by: EMRG Evolution <emrg@argszero.dev>
Sign up for freeto 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

@argszero