From 13c7c289538189a23eaf72e3441084b39f1e7c65 Mon Sep 17 00:00:00 2001 From: Josephasafg Date: Thu, 25 Apr 2024 15:56:20 +0300 Subject: [PATCH 1/2] fix: num_retries method --- ai21/http_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ai21/http_client.py b/ai21/http_client.py index eefef99c..08476fd9 100644 --- a/ai21/http_client.py +++ b/ai21/http_client.py @@ -46,7 +46,7 @@ def requests_retry_session(session, retries=0): connect=retries, backoff_factor=RETRY_BACK_OFF_FACTOR, status_forcelist=RETRY_ERROR_CODES, - method_whitelist=frozenset(RETRY_METHOD_WHITELIST), + allowed_methods=frozenset(RETRY_METHOD_WHITELIST), ) adapter = HTTPAdapter(max_retries=retry) session.mount("https://", adapter) From aec8b5946112cb7d508f3a3a6aa43198134ef790 Mon Sep 17 00:00:00 2001 From: Josephasafg Date: Thu, 25 Apr 2024 16:40:08 +0300 Subject: [PATCH 2/2] fix: Added 408 for retries --- ai21/http_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ai21/http_client.py b/ai21/http_client.py index 08476fd9..229c5156 100644 --- a/ai21/http_client.py +++ b/ai21/http_client.py @@ -19,7 +19,7 @@ DEFAULT_NUM_RETRIES = 0 RETRY_BACK_OFF_FACTOR = 0.5 TIME_BETWEEN_RETRIES = 1000 -RETRY_ERROR_CODES = (429, 500, 503) +RETRY_ERROR_CODES = (408, 429, 500, 503) RETRY_METHOD_WHITELIST = ["GET", "POST", "PUT"]