wow-token-app-bot

An interactions.py Discord bot for getting and alerting on the WoW Token Price
git clone https://git.emily.sh/wowtoken-app/wow-token-app-bot.git
Log | Files | Refs | README | LICENSE

commit df0cd8b40e99aabd8d0fff12502e8aec2b1fa577
parent 5a34e6f3ed0c524f03545e5ddf874406363809bb
Author: Emily Doherty <git@emily.sh>
Date:   Sun,  8 Dec 2024 18:22:28 -0800

Properly scream when token database unreachable

This increases the retries before giving up and gives a backoff if it's failed once but if token data is unavailable scream loudly

Diffstat:
Mtoken_bot/token_database/database.py | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git 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: