Skip to main content

new version async retrying package.

Project description

info:

Simple retrying for asyncio

https://img.shields.io/pypi/v/aio_retrying.svg

Installation

pip install aio_retrying

Usage

import asyncio

import aiohttp

from Utils.async_retrying import retry


class Aio:
    def __init__(self):
        self.session = aiohttp.ClientSession()

    async def __aenter__(self):
        return self

    @retry(attempts=3, delay=1, fallback="daoji")
    async def __aexit__(self, exc_type, exc_val, exc_tb):
        await self.session.close()
        print("exit")

    async def main(self):
        for i in range(3):
            assert self.session.closed is False
            await asyncio.sleep(1)
            print(f"task - {i}")


async def second_aio():
    aio = Aio()
    # task = asyncio.create_task(aio.main())
    # task.add_done_callback(lambda _: asyncio.create_task(aio.__aexit__(None, None, None)))
    ret = await aio.__aexit__(None, None, None)
    print(f"结果:{ret}")


async def first_aio():
    await second_aio()
    while True:
        # print("first")
        await asyncio.sleep(3)


def main():
    asyncio.run(first_aio())


if __name__ == "__main__":
    main()

Python 3.8+ is required

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aio_retrying-1.0.3.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

aio_retrying-1.0.3-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file aio_retrying-1.0.3.tar.gz.

File metadata

  • Download URL: aio_retrying-1.0.3.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.1 Darwin/23.1.0

File hashes

Hashes for aio_retrying-1.0.3.tar.gz
Algorithm Hash digest
SHA256 1228c2473d041019a717ef569073ac2c39c0f6adcbf0a2f675c0fc847d883b99
MD5 ec533a8ca4fc55012b93b79d78d20f78
BLAKE2b-256 43254773a752a32d1297da0db335cc0310eb204e9c7e812c4547a9c240169fa0

See more details on using hashes here.

File details

Details for the file aio_retrying-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: aio_retrying-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.1 Darwin/23.1.0

File hashes

Hashes for aio_retrying-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ce3c281091b136108e8f7fef8a786fdbcc40f7d549e6d3f15b243d4a614f7881
MD5 217c79dc0f126defafeb81a4b76fa58e
BLAKE2b-256 5bbf1201cae38dfc37bfd2d4742a21b9947809b4f15073a53cc91b0cb82d5b94

See more details on using hashes here.

Supported by

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