Skip to content

Commit

Permalink
add broader retry on http client
Browse files Browse the repository at this point in the history
  • Loading branch information
jalexanderII committed Aug 22, 2024
1 parent 7b08343 commit 6b6a0ba
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions parea/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ def request(
if e.response.status_code == 422:
# update the error message to include the validation errors
e.args = (f"{e.args[0]}: {e.response.json()}",)
logger.error(
f"HTTP error {e.response.status_code} for {e.request.method} with: {e.args}",
extra={"request_data": data, "request_params": params},
)
raise
except httpx.TimeoutException as e:
logger.error(
Expand Down Expand Up @@ -100,6 +104,10 @@ async def request_async(
if e.response.status_code == 422:
# update the error message to include the validation errors
e.args = (f"{e.args[0]}: {e.response.json()}",)
logger.error(
f"HTTP error {e.response.status_code} for {e.request.method} with: {e.args}",
extra={"request_data": data, "request_params": params},
)
raise
except httpx.TimeoutException as e:
logger.error(
Expand Down Expand Up @@ -137,6 +145,10 @@ def stream_request(
if e.response.status_code == 422:
# update the error message to include the validation errors
e.args = (f"{e.args[0]}: {e.response.json()}",)
logger.error(
f"HTTP error {e.response.status_code} for {e.request.method} with: {e.args}",
extra={"request_data": data, "request_params": params},
)
raise
except httpx.TimeoutException as e:
logger.error(
Expand Down Expand Up @@ -174,6 +186,10 @@ async def stream_request_async(
if e.response.status_code == 422:
# update the error message to include the validation errors
e.args = (f"{e.args[0]}: {e.response.json()}",)
logger.error(
f"HTTP error {e.response.status_code} for {e.request.method} with: {e.args}",
extra={"request_data": data, "request_params": params},
)
raise
except httpx.TimeoutException as e:
logger.error(
Expand Down

0 comments on commit 6b6a0ba

Please sign in to comment.