Skip to content

Commit

Permalink
retry 408 and 429 statuses in legacy client (#829)
Browse files Browse the repository at this point in the history
* retry 408 and 429 statuses in legacy client

* changelog

* more consistency in catching exceptions

* fix duplicate handling
  • Loading branch information
pkasprzyk authored Jan 20, 2022
1 parent ff3d394 commit 620b126
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

## Fixes
- Raise proper exception when invalid token were provided ([#825](https://github.com/neptune-ai/neptune-client/pull/825))
- Make status error-handling in legacy client consistent with neptune.new ([#829](https://github.com/neptune-ai/neptune-client/pull/829))

## neptune-client 0.14.2

Expand Down
10 changes: 8 additions & 2 deletions neptune/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
HTTPServerError,
HTTPServiceUnavailable,
HTTPUnauthorized,
HTTPTooManyRequests,
)
from urllib3.exceptions import NewConnectionError

from neptune import envs
from neptune.api_exceptions import (
Expand Down Expand Up @@ -324,6 +326,9 @@ def wrapper(*args, **kwargs):
HTTPRequestTimeout,
HTTPGatewayTimeout,
HTTPBadGateway,
HTTPTooManyRequests,
HTTPServerError,
NewConnectionError,
):
if retry >= 6:
_logger.warning(
Expand All @@ -332,8 +337,6 @@ def wrapper(*args, **kwargs):
time.sleep(2 ** retry)
retry += 1
continue
except HTTPServerError:
raise ServerError()
except HTTPUnauthorized:
raise Unauthorized()
except HTTPForbidden:
Expand All @@ -357,9 +360,12 @@ def wrapper(*args, **kwargs):
time.sleep(2 ** retry)
continue
elif status_code in (
HTTPRequestTimeout.status_code,
HTTPBadGateway.status_code,
HTTPServiceUnavailable.status_code,
HTTPGatewayTimeout.status_code,
HTTPTooManyRequests.status_code,
HTTPServerError.status_code,
):
if retry >= 6:
_logger.warning(
Expand Down

0 comments on commit 620b126

Please sign in to comment.