🚧 Initial work on retryable managers

This commit is contained in:
GeoffreyCoulaud
2023-05-31 15:22:08 +02:00
parent 743db2b747
commit 0b188136a2
6 changed files with 52 additions and 26 deletions

View File

@@ -1,13 +1,18 @@
from requests import HTTPError, JSONDecodeError
from src.game import Game
from src.store.managers.async_manager import AsyncManager
from src.utils.steam import SteamGameNotFoundError, SteamHelper, SteamNotAGameError
from src.utils.steam import (
HTTPError,
SteamGameNotFoundError,
SteamHelper,
SteamNotAGameError,
)
class SteamAPIManager(AsyncManager):
"""Manager in charge of completing a game's data from the Steam API"""
retryable_on = set((HTTPError,))
def final_run(self, game: Game) -> None:
# Skip non-steam games
if not game.source.startswith("steam_"):
@@ -18,9 +23,6 @@ class SteamAPIManager(AsyncManager):
steam = SteamHelper()
try:
online_data = steam.get_api_data(appid=appid)
except (HTTPError, JSONDecodeError) as error:
# On minor error, just report it
self.report_error(error)
except (SteamNotAGameError, SteamGameNotFoundError):
game.update_values({"blacklisted": True})
else: