Simple retry cient for aiohttp
Project description
This package is similar to Tornado-retry-client.
Python 3.5+.
Install: pip install aiohttp-retry.
Github: https://github.com/inyutin/aiohttp_retry
Examples of usage:
from aiohttp_retry import RetryClient
async def main():
retry_client = RetryClient(raise_for_status=False)
async with retry_client.get('https://ya.ru', retry_attempts=1) 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)
Be aware: last request returns as it is.
Documentation
RetryClient takes the same arguments as ClientSession[docs]
RetryClient has methods:
- get
- options
- head
- post
- put
- patch
- put
- delete
They are same as for ClientSession, but take additional arguments:
from typing import Optional, Set, Type
retry_attempts: int = 3, # How many times we should retry
retry_start_timeout: float = 0.1, # Base timeout time, then it exponentially grow
retry_max_timeout: float = 30, # Max possible timeout between tries
retry_factor: float = 2, # How much we increase timeout each time
retry_for_statuses: Optional[Set[int]] = None, # On which statuses we should retry
retry_exceptions: Optional[Set[Type]] = None, # On which exceptions we should 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
aiohttp_retry-1.1.5.tar.gz
(3.2 kB
view details)
File details
Details for the file aiohttp_retry-1.1.5.tar.gz.
File metadata
- Download URL: aiohttp_retry-1.1.5.tar.gz
- Upload date:
- Size: 3.2 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 |
41a2d95af23113d72486ade4ec996f40ad968ea4a1ff59c5222613b15c340c98
|
|
| MD5 |
83fa12fc8c09e4b42b81b7014f1dfbfb
|
|
| BLAKE2b-256 |
18c985266047ca391b462e1063608a2c6b191c6a213995b50eef152441ba2e68
|