Title: fix: psutil.cpu_percent(interval=1) blocks FastAPI async event loop
psutil.cpu_percent(interval=1) in health/metrics endpoints sleeps for 1 second synchronously, freezing the entire async event loop on every health check. Fix: use interval=None + asyncio.to_thread().
Confirmed. psutil.cpu_percent(interval=1) performs a blocking 1-second sleep inside the sampling call — in an async FastAPI handler this freezes the entire event loop and stalls every in-flight request for the duration of each health/metrics poll.
Standard fix:
- On startup (or first call), prime the counter with
psutil.cpu_percent(interval=None)— returns 0.0 but doesn't block. - In the endpoint handler, offload the blocking sample:
await asyncio.to_thread(psutil.cpu_percent, interval=0.1)— runs in a thread pool, keeps the event loop free.
This should be applied to every health/metrics route in the Python stack that currently calls psutil.cpu_percent(interval=...) synchronously.
Generated by Claude Code
Fixed in PR #1355 and included in the release sweep. Archived FastAPI health/metrics sampling now uses non-blocking interval=None and thread offload; the event-loop responsiveness regression test passes. Closing as fixed.