diff --git a/parea/api_client.py b/parea/api_client.py index 50cdc106..0e0390a5 100644 --- a/parea/api_client.py +++ b/parea/api_client.py @@ -30,7 +30,7 @@ async def async_wrapper(*args, **kwargs): for retry in range(MAX_RETRIES): try: return await func(*args, **kwargs) - except (httpx.HTTPStatusError, httpx.ConnectError) as e: + except httpx.HTTPError as e: if not _should_retry(e, retry): raise await asyncio.sleep(BACKOFF_FACTOR * (2**retry)) @@ -40,7 +40,7 @@ def sync_wrapper(*args, **kwargs): for retry in range(MAX_RETRIES): try: return func(*args, **kwargs) - except (httpx.HTTPStatusError, httpx.ConnectError) as e: + except httpx.HTTPError as e: if not _should_retry(e, retry): raise time.sleep(BACKOFF_FACTOR * (2**retry)) @@ -49,7 +49,7 @@ def _should_retry(error, current_retry): """Determines if the function should retry on error.""" is_502_error = isinstance(error, httpx.HTTPStatusError) and error.response.status_code == 502 is_last_retry = current_retry == MAX_RETRIES - 1 - return not is_last_retry and (isinstance(error, httpx.ConnectError) or is_502_error) + return not is_last_retry and (isinstance(error, (httpx.ConnectError, httpx.ReadError)) or is_502_error) if asyncio.iscoroutinefunction(func): return async_wrapper diff --git a/pyproject.toml b/pyproject.toml index 5de671ac..421ce6ed 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "parea-ai" packages = [{ include = "parea" }] -version = "0.2.147" +version = "0.2.148" description = "Parea python sdk" readme = "README.md" authors = ["joel-parea-ai "]