Skip to content

Is an async retry_error_callback possible? #249

@tetienne

Description

@tetienne

My lib uses aiohttp. I want a retry mechanism when we are logout from the server. So here what I write:

async def relogin(retry_state):
    await retry_state.args[0].login()
    print(retry_state)

@retry(
        retry=retry_if_exception_type(NotAuthenticatedException),
        stop=stop_after_attempt(1),
        retry_error_callback=relogin
    )
    async def execute_scenario(self, oid: str) -> str:
        response = await self.__post(f"exec/{oid}")
        return response["execId"]

Sadly, I got

sys:1: RuntimeWarning: coroutine 'relogin' was never awaited
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

What I want to achieve is not possible?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions