diff --git a/token_bot/token_database/database.py b/token_bot/token_database/database.py index 77b4702..11be071 100644 --- a/token_bot/token_database/database.py +++ b/token_bot/token_database/database.py @@ -1,3 +1,4 @@ +import asyncio from typing import Dict, List import aiohttp @@ -17,13 +18,16 @@ class Database: success = False tries = 0 + backoff = 0.1 - while not success and tries < 3: + while not success and tries <= 5: + if tries > 1: + await asyncio.sleep(backoff * tries) try: return await self._external_call(url) except TokenHttpException: tries += 1 - return {} + raise TokenHttpException async def _external_call(self, url) -> Dict | List: async with self.session.get(url) as resp: