Use backoff with asyncio coroutines
masterBackoff supports asynchronous execution. Simply apply @backoff.on_exception or @backoff.on_predicate to async def coroutines. Event handlers (on_success, on_backoff, on_giveup) can also be coroutines.
@backoff.on_exception(backoff.expo, aiohttp.ClientError, max_time=60)
async def get_url(url):
async with aiohttp.ClientSession(raise_for_status=True) as session:
async with session.get(url) as response:
return await response.text()