Speed up football refresh (batch 24) + skip caching on API errors

This commit is contained in:
JinwooKim committed 2026-06-15 16:08:30 +09:00
1 parent 4246ad6936
commit dc262009f9
2 files changed
+10 -3

No files matched your search

+7 -1
View File
@@ -87,8 +87,14 @@ async def _get(client: httpx.AsyncClient, path: str, **params) -> dict:
timeout=25,
)
r.raise_for_status()
data = r.json()
# API-Football 은 한도초과·레이트·파라미터 오류를 HTTP 200 + errors 로 준다.
# 빈 응답을 정상으로 오해해 빈 데이터를 캐싱하지 않도록 여기서 예외 발생.
errs = data.get("errors")
if errs: # 빈 리스트([])는 정상, 채워진 dict 면 오류
raise RuntimeError(f"API-Football error: {errs}")
await asyncio.sleep(settings.football_call_interval_sec) # 10/분 제한 회피
return r.json()
return data
# ── 캐시 upsert ────────────────────────────────────────────────