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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for aiohttp_retry-1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a768491d7a61882c77bbb40ff4ae9395b67ba49b73027dc2e04d0889b182bb4 |
|
MD5 | b3f6e26b61f14d6817662f13437542f2 |
|
BLAKE2b-256 | 36bc30ef27ac83c2afd558bb6f5d0462fcb9a8d49d2a2d9dfc2da4b5889208ce |