Fix API hang — switch gaze push from httpx to urllib

httpx.post creates a new connection per call at 10Hz, causing connection
pile-up that eventually blocks the event loop. urllib is lightweight and
stateless — no connection pooling overhead.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Alex
2026-04-12 21:22:42 -05:00
parent 8f71d97af6
commit c7b0be3319

View File

@@ -464,13 +464,16 @@ def doa_track_loop():
def _push_gaze(x: int, y: int): def _push_gaze(x: int, y: int):
"""Fire-and-forget gaze push to eye service.""" """Fire-and-forget gaze push to eye service. Uses urllib to avoid httpx connection overhead."""
try: try:
import httpx import urllib.request
httpx.post(f"{EYE_SERVICE_URL}/gaze", data = json.dumps({"x": x, "y": y}).encode()
json={"x": x, "y": y}, timeout=0.5) req = urllib.request.Request(
f"{EYE_SERVICE_URL}/gaze", data=data,
headers={"Content-Type": "application/json"})
urllib.request.urlopen(req, timeout=0.3)
except Exception: except Exception:
pass # eye service may be down, don't spam logs pass
# ============================================================================ # ============================================================================