Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is an async retry_error_callback possible? #249

Closed
tetienne opened this issue Aug 27, 2020 · 2 comments · Fixed by #437 · May be fixed by #363
Closed

Is an async retry_error_callback possible? #249

tetienne opened this issue Aug 27, 2020 · 2 comments · Fixed by #437 · May be fixed by #363

Comments

@tetienne
Copy link

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?

@michaeloliverx
Copy link

Support for async callbacks would be awesome!

@symphony-youness
Copy link

symphony-youness commented Mar 16, 2021

+1
Hi @tetienne did you by any chance manage to find a workaround for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment