fix(gdelt): stop retrying 429 over http, add quota backoff
GDELT's DOC 2.0 API answers 429 with a plain-text body, no Retry-After, and a per-IP block window that widens with request volume. The https->http retry only doubled the request count against that quota and could never succeed, and every cycle logged a full traceback. - ingest_gdelt: a 429 (or a 200 with a prose body) now sets a backoff window (GDELT_BACKOFF_BASE=300s, doubling to GDELT_BACKOFF_MAX=1800s, Retry-After honoured when present) and returns 0 instead of raising. - cycles inside the window skip the call entirely, logging one line. - the https->http fallback now only covers TransportError (TLS/connect), not HTTP error statuses. - producer_loop logs a GDELT failure as one WARNING line, no traceback. - tests/test_gdelt_backoff.py covers no-retry-on-429, cooldown skip, doubling and cap, Retry-After, 200-prose, success reset, transport fallback.
This commit is contained in:
parent
54897b49bc
commit
56908aed03
3 changed files with 300 additions and 10 deletions
|
|
@ -56,8 +56,11 @@ async def producer_loop() -> None:
|
|||
try:
|
||||
g = await ingest_gdelt(query=GDELT_QUERY, max_articles=50)
|
||||
logger.info("GDELT -> %d articles", g)
|
||||
except Exception: # noqa: BLE001
|
||||
logger.exception("GDELT fetch failed")
|
||||
except Exception as exc: # noqa: BLE001
|
||||
# Quota/backoff cases are handled inside ingest_gdelt (one clean
|
||||
# line); anything reaching here is a real failure and a stack
|
||||
# trace every 5 minutes is not actionable, so keep it to one line.
|
||||
logger.warning("GDELT fetch failed: %s", exc)
|
||||
if ENABLE_QUAKES:
|
||||
try:
|
||||
q = await ingest_earthquakes()
|
||||
|
|
|
|||
Loading…
Reference in a new issue