Skip to main content

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


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

If you're not sure about the file name format, learn more about wheel file names.

aiohttp_retry-1.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file aiohttp_retry-1.0-py3-none-any.whl.

File metadata

  • Download URL: aiohttp_retry-1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1

File hashes

Hashes for aiohttp_retry-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0a768491d7a61882c77bbb40ff4ae9395b67ba49b73027dc2e04d0889b182bb4
MD5 b3f6e26b61f14d6817662f13437542f2
BLAKE2b-256 36bc30ef27ac83c2afd558bb6f5d0462fcb9a8d49d2a2d9dfc2da4b5889208ce

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page