diff --git a/manifest/clients/client.py b/manifest/clients/client.py index 932474b..64c136b 100644 --- a/manifest/clients/client.py +++ b/manifest/clients/client.py @@ -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 @@ -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