Simple retry cient for aiohttp
Project description
Install: pip install aiohttp-retry.
Warning
Examples of usage:
from aiohttp_retry import RetryClient, RetryOptions
async def main():
retry_options = RetryOptions(attempts=1)
retry_client = RetryClient(raise_for_status=False, retry_options=retry_options)
async with retry_client.get('https://ya.ru') as response:
print(response.status)
await retry_client.close()
from aiohttp_retry import RetryClient
async def main():
async with RetryClient() as client:
async with client.get('https://ya.ru') as response:
print(response.status)
Documentation
They are same as for ClientSession, but take one possible additional argument:
from typing import Optional, Set, Type
class RetryOptions:
def __init__(
self,
attempts: int = 3, # How many times we should retry
start_timeout: float = 0.1, # Base timeout time, then it exponentially grow
max_timeout: float = 30.0, # Max possible timeout between tries
factor: float = 2.0, # How much we increase timeout each time
statuses: Optional[Set[int]] = None, # On which statuses we should retry
exceptions: Optional[Set[Type[Exception]]] = None, # On which exceptions we should retry
)
...
You can specify RetryOptions both for RetryClient and it’s methods. RetryOptions in methods override RetryOptions defined in RetryClient constructor.
Development
Before creating PR please run mypy: mypy -m aiohttp_retry
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aiohttp_retry-2.0.tar.gz.
File metadata
- Download URL: aiohttp_retry-2.0.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.0 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd64475735bfc018a1266c4302a7f360e37b799a77a431d79cc1af18abcd42b3
|
|
| MD5 |
03ca55c193ba1aac1f01eae550ba2810
|
|
| BLAKE2b-256 |
597e39186a37b1b7794b785b727a7822aa5e8b8f709f2ae0d250210444fe40d5
|
File details
Details for the file aiohttp_retry-2.0-py3-none-any.whl.
File metadata
- Download URL: aiohttp_retry-2.0-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7fcdb7b48ea96012c1f594464f8310d2728844e8930424fc5dfdc1a27802d061
|
|
| MD5 |
b17513a6f38dc727027acb4cd8f9bb6d
|
|
| BLAKE2b-256 |
b998cc1386ea71374bcb8a9b393396c30e79198132e1672c31f053b86e9bb3e1
|