Skip to content

Commit 9d45d4f

Browse files
committed
Retry on HTTP 500
1 parent afe4353 commit 9d45d4f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

plexanisync/graphql.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ def update_score(self, media_id, score_raw: int):
189189
self.__send_graphql_request(op)
190190

191191
def __send_graphql_request(self, operation):
192+
retries = 10
193+
192194
while True:
193195
data = self.endpoint(operation)
194196
if "errors" in data:
@@ -199,11 +201,14 @@ def __send_graphql_request(self, operation):
199201
logger.warning(f"Rate limit hit, waiting for {wait_time}s")
200202
time.sleep(wait_time + 1)
201203

204+
elif retries > 0:
205+
retries = retries - 1
206+
time.sleep(1)
202207
else:
203208
raise data["exception"]
204209
else:
205210
# wait a bit to not overload AniList API
206-
time.sleep(1)
211+
time.sleep(0.2)
207212
return data
208213

209214
def __mediaitem_to_object(self, media_item) -> AnilistSeries:

0 commit comments

Comments
 (0)