How does sleep with backoff_factor work in Python requests? or Is sleep with backoff_factor the best

18 Replies, 2114 Views

Backoff_factor is just math, dude. You multiply your wait time by 2^n (n = retry count).

So:
- 1st fail: wait 1s
- 2nd fail: wait 2s
- 3rd fail: wait 4s
... and so on.

It’s exponential, so it *feels* slow, but it’s way better than getting IP-banned.

If you’re lazy, use `requests.Session()` with `HTTPAdapter(max_retries=...)`. It has basic backoff built in.

Messages In This Thread



Users browsing this thread: 1 Guest(s)