Metadata-Version: 2.1
Name: spoqa-requests-backoff
Version: 0.1.1
Summary: Backoff Session for requests
Home-page: https://github.com/spoqa/requests-backoff
License: MIT
Author: Spoqa Creators
Author-email: dev@spoqa.com
Maintainer: rusty
Maintainer-email: rusty@spoqa.com
Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Requires-Dist: backoff (>=1.10.0,<2.0.0)
Requires-Dist: requests (>=2.25.1,<3.0.0)
Project-URL: Repository, https://github.com/spoqa/requests-backoff
Description-Content-Type: text/markdown

# spoqa-requests-backoff

[![MIT License](https://badgen.net/badge/license/MIT/cyan)](LICENSE)
[![PyPI](https://badgen.net/pypi/v/spoqa-requests-backoff)](https://pypi.org/project/spoqa-requests-backoff/)

Backoff session for requests

## Usage

```python
resp = BackoffSession().get('https://...')
```

By default, `BackoffSession` tries before giving up until any following condition is met:

- Tries 10 times
- Reaches 20 seconds
- Meets `requests.RequestException`
- Meets HTTP client error (4xx)

Behaviors above can be customized with parameters.

```python
BackoffSession(
    exception=(RequestException, ValueError),  # Give up when ValueError occurs, too.
    max_tries=100,  # Tries 100 times before giving up
    max_time=300,  # Wait until maximum 300 seconds before giving up
    giveup=lambda e: e.response.text == 'You're fired!'  # Give up when specific response is met
)
```

BackoffSession heavily depends on [`backoff`](https://github.com/litl/backoff) package.

## License

_spoqa-requests-backoff_ is distributed under the terms of MIT License.

See [LICENSE](LICENSE) for more details.

