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 hashes)