fix(avito): tolerate 429 per-bucket instead of banning whole sweep #1769
No reviewers
Labels
No labels
admin
analytics
auth
automation
bug
business
chore
ci
compliance
data
data-moat
docs
duplicate
dx
enhancement
Fable 5 ревью
feedback/max
generative
GG-форсайт
needs-discussion
needs-human
observability
pause-bots
performance
priority/p0
priority/p1
priority/p2
priority/p3
scope/backend
scope/db
scope/devops
scope/frontend
scope/qa
scrapers
security
site-finder
stage/1
stage/2
status/blocked
status/done
status/needs-analysis
status/needs-fix
status/qa
status/ready
status/review
status/wip
tech-debt
tradein
ux
week ревью 1
wontfix
вторичка
ИРД
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lekss361/gendesign#1769
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "fix/avito-429-bucket-skip"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem (prod run 216)
The merged 403 reconnect-retry works — run 216 recovered two 403s and got 2.4× further than ever (29 buckets, active 4360→5857). But it then banned on a 429 at page 36 (deep pagination of a dense bucket). The 429 path had only
_AVITO_429_MAX_RETRIES=4same-session short-retries, then raisedAvitoRateLimitedError→ propagated → whole runmark_banned.Fix
A.
_fetch_serp_html429 path:_AVITO_429_MAX_RETRIES4 → 8 (same-session short-retry stays the first line)._AVITO_429_RECONNECT_RETRIES=3: on short-retry exhaustion under backconnect, do up to 3_reset_cffi()+ backoff reconnect attempts (fresh connection releases the held conn-limit slot) before raising. Mirrors the 403 reconnect block. 403/firewall logic untouched.B.
fetch_all_secondaryper-bucket skip (new_AVITO_SWEEP_MAX_CONSECUTIVE_BLOCKED=4):_walk_price_range) and incremental (_paginate_incremental_bracket) bracket calls wrapped intry/except (AvitoRateLimitedError, AvitoBlockedError). On block: log,consecutive_blocked += 1,skipped_blocked += 1,continue. On any success: reset counter.consecutive_blocked >= 4→ re-raise (preserves real hard-ban detection →run_avito_full_loadstill marks banned). So an isolated deep-bucket 429 skips that bucket and the sweep continues; only a sustained block run aborts.skipped_blocked=N.Tests
New
tests/scrapers/test_avito_429_bucket_skip.py(429 widened-retry → 200, 429-exhausted → reconnect → 200, fully exhausted → raise; per-bucket skip continues sweep; 4-consecutive → propagates; success resets counter). Adjusted one pre-existing test that hard-coded the old 429 count (now constant-derived).tests/scrapers/ -k avito: 78 passed; fulltests/scrapers/: 143 passed. Ruff clean.Complements the schedule split (incremental avoids deep pages; this hardens the weekly exhaustive run).