Skip to content

Allow Custom Sleep Function #125

Open
@stevenjackson121

Description

@stevenjackson121

I think it would be great to add a sleep argument which defaults to asyncio.sleep to improve support for event loops besides asyncio, while keeping it working out of the box for asyncio. I like backoff and would like to stick with it, but it ended up being too much of a hassle to get it working with trio.

tenacity has this feature, with the following syntax/explanation.

You can even use alternative event loops such as curio or Trio by passing the correct sleep function:
    
    @retry(sleep=trio.sleep)
    async def my_async_function(loop):
        await asks.get('https://example.org')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions