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

Issue with aiohttp example #69

Closed
farbodsalimi opened this issue Jan 14, 2019 · 1 comment
Closed

Issue with aiohttp example #69

farbodsalimi opened this issue Jan 14, 2019 · 1 comment

Comments

@farbodsalimi
Copy link

I'm not sure if I'm doing something wrong or your aiohttp example is wrong! Seems backoff decorator doesn't catch aiohttp exceptions automatically and you need to raise the error manually:

@backoff.on_exception(backoff.expo,
                      aiohttp.ClientError,
                      max_tries=4)
async def get_url(url):
    async with aiohttp.ClientSession() as session:
        async with session.get(url) as response:
            response.raise_for_status()
            return await response.text()

if I remove response.raise_for_status() from the code above, no retries will happend on aiohttp.ClientError.

@fabien-sarcel
Copy link

fabien-sarcel commented Nov 6, 2020

async with aiohttp.ClientSession(raise_for_status=True) as session:

By default aiohttp doesn't raise exception for non-200 status. You should change it passing raise_for_status=True. see post on stackoverflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants