From dd3d5f3670bbc04ec192a37a93a6ec200c07bc4e Mon Sep 17 00:00:00 2001 From: ducklet Date: Tue, 2 Nov 2021 14:14:32 +0100 Subject: [PATCH] fix user rating refresh if a user is unavailable If a user's ratings cannot be accessed, e.g. due to network errors, it should skip to the next user. Ideally we could mark a user as inactive after X failed retries. --- unwind/imdb.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/unwind/imdb.py b/unwind/imdb.py index 666f8ed..5159fa9 100644 --- a/unwind/imdb.py +++ b/unwind/imdb.py @@ -44,13 +44,17 @@ async def refresh_user_ratings_from_imdb(stop_on_dupe=True): log.info("⚡️ Loading data for %s ...", user.name) - async for rating, is_updated in load_ratings(user.imdb_id): - assert rating.user.id == user.id + try: + async for rating, is_updated in load_ratings(user.imdb_id): + assert rating.user.id == user.id - if stop_on_dupe and not is_updated: - break + if stop_on_dupe and not is_updated: + break - yield rating + yield rating + + except BaseException as err: + log.error("❌ Could not load rating for %s!", user.name, exc_info=err) def user_ratings_url(user_id):