Skip to content

Commit

Permalink
chore: try catch around retry error (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
lorr1 authored Apr 9, 2023
1 parent 0fb192a commit f2e6ec9
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions manifest/clients/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import logging
import math
from abc import ABC, abstractmethod
from typing import Any, Dict, List, Optional, Tuple, Union
from typing import Any, Dict, List, Optional, Tuple, Union, cast

import aiohttp
import requests
Expand All @@ -18,9 +18,15 @@

def retry_if_ratelimit(retry_base: RetryCallState) -> bool:
"""Return whether to retry if ratelimited."""
if isinstance(retry_base.outcome.exception(), requests.exceptions.HTTPError):
if retry_base.outcome.exception().response.status_code == 429: # type: ignore
return True
try:
if isinstance(retry_base.outcome.exception(), requests.exceptions.HTTPError):
exception = cast(
requests.exceptions.HTTPError, retry_base.outcome.exception()
)
if exception.response.status_code == 429: # type: ignore
return True
except Exception:
pass
return False


Expand Down

0 comments on commit f2e6ec9

Please sign in to comment.