From 9d45d4ffafe5710f368a28f1fe210b7e895aea69 Mon Sep 17 00:00:00 2001 From: reconman Date: Sun, 18 Feb 2024 21:18:37 +0100 Subject: [PATCH] Retry on HTTP 500 --- plexanisync/graphql.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plexanisync/graphql.py b/plexanisync/graphql.py index dd0b29a..02e7378 100644 --- a/plexanisync/graphql.py +++ b/plexanisync/graphql.py @@ -189,6 +189,8 @@ def update_score(self, media_id, score_raw: int): self.__send_graphql_request(op) def __send_graphql_request(self, operation): + retries = 10 + while True: data = self.endpoint(operation) if "errors" in data: @@ -199,11 +201,14 @@ def __send_graphql_request(self, operation): logger.warning(f"Rate limit hit, waiting for {wait_time}s") time.sleep(wait_time + 1) + elif retries > 0: + retries = retries - 1 + time.sleep(1) else: raise data["exception"] else: # wait a bit to not overload AniList API - time.sleep(1) + time.sleep(0.2) return data def __mediaitem_to_object(self, media_item) -> AnilistSeries: