I’ve been down this rabbit hole too! Ended up using `backoff` lib because it’s stupid simple and has sane defaults.
Example:
```python
import backoff
import requests
@backoff.on_exception(backoff.expo, requests.exceptions.RequestException, max_tries=3)
def get_data():
return requests.get("https://api.example.com")
```
Exponential backoff is baked in, and you can add jitter if you want.
Example:
```python
import backoff
import requests
@backoff.on_exception(backoff.expo, requests.exceptions.RequestException, max_tries=3)
def get_data():
return requests.get("https://api.example.com")
```
Exponential backoff is baked in, and you can add jitter if you want.
