mirror of
https://github.com/wahyd4/links.git
synced 2026-08-08 21:04:53 +10:00
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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user