Python Backoff Decorator
========================
This package implements exponential backoff as a decorator. Backoff is
triggered by an exception and is reset when the call is successful.
Usage
-----
Apply exponential backoff to any function or method by simply adding the
decorator:
```python
import backoff
import requests
@backoff.Backoff()
def send_data(data):
requests.post('https://example.com/data', data={'data': data})
try:
send_data('foo')
except:
# do something with data that wasn't posted
```
In the example above calls to `send_data()` will exponentially backoff when
POST is not successful.
Calls During Backoff Period
---------------------------
Any calls made during the backoff period will raise an `InBackoff` exception.
Setting Maximum Backoff
-----------------------
By default the maximum backoff is 1 hour. The `max_backoff` argument can be
passed to change the default; the following will only backoff for 5 minutes:
```python
@backoff.Backoff(max_backoff=300)
def send_data(data):
requests.post('https://example.com/data', data={'data': data})
```
========================
This package implements exponential backoff as a decorator. Backoff is
triggered by an exception and is reset when the call is successful.
Usage
-----
Apply exponential backoff to any function or method by simply adding the
decorator:
```python
import backoff
import requests
@backoff.Backoff()
def send_data(data):
requests.post('https://example.com/data', data={'data': data})
try:
send_data('foo')
except:
# do something with data that wasn't posted
```
In the example above calls to `send_data()` will exponentially backoff when
POST is not successful.
Calls During Backoff Period
---------------------------
Any calls made during the backoff period will raise an `InBackoff` exception.
Setting Maximum Backoff
-----------------------
By default the maximum backoff is 1 hour. The `max_backoff` argument can be
passed to change the default; the following will only backoff for 5 minutes:
```python
@backoff.Backoff(max_backoff=300)
def send_data(data):
requests.post('https://example.com/data', data={'data': data})
```
Release files for exbackoff 1.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| exbackoff-1.1.2.tar.gz | 2.6 kB | Details |
Release files / exbackoff-1.1.2.tar.gz
| Download URL | exbackoff-1.1.2.tar.gz |
|---|---|
| Size | 2.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8ba441ad8a56fb47afdb718430e31485c35a329cd02513bd1dfdc12e698be8a4
|
|
BLAKE2b-256 checksum How to use checksums |
14d3709397b8e4e6d866506bd9154d17f11a3ed47b4ce5f5255e95594841d33a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |