Getting hit with HTTP error 429 - how do I handle too many requests? or HTTP error 429: What’s the be

16 Replies, 921 Views

Man, http error 429 is a nightmare.

If you’re lazy (like me), just use `backoff` lib. Here’s how:

```python
import backoff
import requests

@backoff.on_exception(backoff.expo, requests.exceptions.HTTPError, max_tries=5)
def make_request():
r = requests.get("your_api_url")
r.raise_for_status()
return r
```

It’ll handle the backoff for you. Easy peasy.

Messages In This Thread



Users browsing this thread: 1 Guest(s)