Skip to content

How can I retry a failed request from the aiohttp client ? #5921

Answered by Dreamsorcerer
iasukas asked this question in Q&A
Discussion options

You must be logged in to vote

Just wrap it an another function?
Something like:

async def retry(...):
    tries = 3
    while tries > 0:
        try:
            return await fetch(...)
        except aiohttp.ClientResponseError:
            if tries <= 0:
                raise
        tries -= 1

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Dreamsorcerer
Comment options

@webknjaz
Comment options

@iasukas
Comment options

Answer selected by webknjaz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants