From 298700539d107e0bdbe46bb1f89f037d7229a3a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Nie=C5=BCurawski?= Date: Fri, 14 May 2021 09:29:03 +0200 Subject: [PATCH] Retry 500 status codes --- neptune/new/internal/backends/utils.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/neptune/new/internal/backends/utils.py b/neptune/new/internal/backends/utils.py index 92ac59661..0f96ff51d 100644 --- a/neptune/new/internal/backends/utils.py +++ b/neptune/new/internal/backends/utils.py @@ -27,14 +27,14 @@ from bravado.client import SwaggerClient from bravado.exception import BravadoConnectionError, BravadoTimeoutError, HTTPForbidden, \ - HTTPInternalServerError, HTTPServerError, HTTPUnauthorized, HTTPServiceUnavailable, HTTPRequestTimeout, \ + HTTPServerError, HTTPUnauthorized, HTTPServiceUnavailable, HTTPRequestTimeout, \ HTTPGatewayTimeout, HTTPBadGateway, HTTPClientError, HTTPTooManyRequests from bravado.http_client import HttpClient from bravado_core.formatter import SwaggerFormat from packaging.version import Version from requests import Session -from neptune.new.exceptions import SSLError, NeptuneConnectionLostException, InternalServerError, \ +from neptune.new.exceptions import SSLError, NeptuneConnectionLostException, \ Unauthorized, Forbidden, CannotResolveHostname, UnsupportedClientVersion, ClientHttpError from neptune.new.internal.backends.api_model import ClientConfig from neptune.new.internal.utils import replace_patch_version @@ -54,12 +54,10 @@ def wrapper(*args, **kwargs): except (BravadoConnectionError, BravadoTimeoutError, requests.exceptions.ConnectionError, requests.exceptions.Timeout, HTTPRequestTimeout, HTTPServiceUnavailable, HTTPGatewayTimeout, HTTPBadGateway, - HTTPTooManyRequests) as e: + HTTPTooManyRequests, HTTPServerError) as e: time.sleep(2 ** retry) last_exception = e continue - except HTTPServerError as e: - raise InternalServerError(e.response.text) from e except HTTPUnauthorized: raise Unauthorized() except HTTPForbidden: @@ -75,12 +73,11 @@ def wrapper(*args, **kwargs): HTTPBadGateway.status_code, HTTPServiceUnavailable.status_code, HTTPGatewayTimeout.status_code, - HTTPTooManyRequests.status_code): + HTTPTooManyRequests.status_code, + HTTPServerError.status_code): time.sleep(2 ** retry) last_exception = e continue - elif status_code >= HTTPInternalServerError.status_code: - raise InternalServerError(e.response.text) from e elif status_code == HTTPUnauthorized.status_code: raise Unauthorized() elif status_code == HTTPForbidden.status_code: