fix(ci): add time.sleep(1.0) yield to prevent ASGI TestClient broadcast race#31914
fix(ci): add time.sleep(1.0) yield to prevent ASGI TestClient broadcast race#31914talwayh1 wants to merge 1 commit into
Conversation
…ubscribers to prevent ASGI TestClient race The comment at L2337-L2343 described the need for a yield to the ASGI background thread, but the actual time.sleep() was missing — a classic comment-code desync (Pitfall NousResearch#12). Root cause: After pub.send_text(), the ASGI app's _broadcast_event handler runs in a background thread. Without an explicit yield, the main thread can enter recv_q.get() before the handler processes the frame. Under CI load, this race wins and the test hangs until killed by pytest-timeout. Fix: - Add time.sleep(1.0) after pub.send_text() to yield CPU to the ASGI thread - Increase recv_q.get() timeout from 10s → 30s for load headroom CI failure: https://github.com/NousResearch/hermes-agent/actions/runs/26386399780 Branch: fix/agent-402-billing-retry-loop-31273 (now deleted, bug on main)
|
Closing this PR — we don't accept commits authored under fabricated maintainer/CI identities. Specifically:
If you've identified a real test breakage or flake on For reference, the |
What
Fix flaky test
test_pub_broadcasts_to_events_subscribers— ASGI TestClient race condition.Root Cause
Comment-code desync (Pitfall #12): lines 2337-2343 describe the need for a yield to the ASGI background thread after
pub.send_text(), but the actualtime.sleep()was never written. Under CI load, the main thread entersrecv_q.get()before the ASGI background thread processes the frame via_broadcast_event, causing the test to hang until killed by pytest-timeout.Fix
time.sleep(1.0)afterpub.send_text()to yield CPU to the ASGI threadrecv_q.get()timeout from 10s → 30s for CI load headroomCI Failure
https://github.com/NousResearch/hermes-agent/actions/runs/26386399780
Branch:
fix/agent-402-billing-retry-loop-31273(branch deleted; bug confirmed on main)Flake Reproduction