fix: handle MaxMind 429 and backoff
This commit is contained in:
@@ -29,6 +29,12 @@ def download_maxmind_mmdb() -> None:
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
tgz = os.path.join(td, "GeoLite2-ASN.tar.gz")
|
||||
r = requests.get(url, timeout=TIMEOUT)
|
||||
if r.status_code == 429:
|
||||
existing = os.path.join(OUT_DIR, "GeoLite2-ASN.mmdb")
|
||||
if os.path.exists(existing):
|
||||
print("[warn] MaxMind rate limited (429); keeping existing mmdb")
|
||||
return
|
||||
raise RuntimeError("MaxMind rate limited (429) and no existing mmdb")
|
||||
r.raise_for_status()
|
||||
with open(tgz, "wb") as f:
|
||||
f.write(r.content)
|
||||
|
||||
Reference in New Issue
Block a user