Skip to content

Commit

Permalink
fix: handle 50X error retrying the request after 30 seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
dylandoamaral committed Jan 30, 2023
1 parent 795243c commit efe12c9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions custom_components/trakt_tv/apis/trakt.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ async def request(self, method, url, **kwargs) -> ClientResponse:
wait_time = int(response.headers["Retry-After"])
await sleep(wait_time)
return await self.request(method, url, **kwargs)
elif response.status in [502, 503, 504]:
await sleep(30)
return await self.request(method, url, **kwargs)
else:
content = await response.text()
error = f"Can't request {url} with {method} because it returns a {response.status} status code with content {content}."
Expand Down

0 comments on commit efe12c9

Please sign in to comment.