routermon: break chunk loop early when circuit breaker fires

Stop sending further API requests mid-batch once the backoff is
triggered, saving remaining missing IPs as empty placeholders
immediately instead of waiting for them to timeout one-by-one.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-04-16 16:35:00 +10:00
co-authored by Copilot
parent 52c39ebdb1
commit 60dd5aeffb
+10
View File
@@ -423,6 +423,16 @@ def _geo_worker_loop():
_geo_consecutive_misses, _GEO_BACKOFF_SECS,
)
_geo_consecutive_misses = 0
# Save remaining uncached IPs and stop the loop early.
remaining = missing[i + 100:]
if remaining:
IPGeoCache.objects.bulk_create(
[IPGeoCache(ip=ip) for ip in remaining
if ip not in geo_cache],
ignore_conflicts=True,
)
_geo_skip.update(remaining)
break
elif results:
_geo_consecutive_misses = 0