From a2e76ad5d03b4a689a81f91f03d0745e74764b9a Mon Sep 17 00:00:00 2001 From: grayroom Date: Mon, 24 Mar 2025 19:34:25 +0900 Subject: [PATCH 1/2] docs(client): fix incorrect comment about timeout calculation. No logic or functional changes. --- src/openai/_base_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openai/_base_client.py b/src/openai/_base_client.py index f31e5af54b..950f524bfa 100644 --- a/src/openai/_base_client.py +++ b/src/openai/_base_client.py @@ -703,7 +703,7 @@ def _calculate_retry_timeout( # Apply exponential backoff, but not more than the max. sleep_seconds = min(INITIAL_RETRY_DELAY * pow(2.0, nb_retries), MAX_RETRY_DELAY) - # Apply some jitter, plus-or-minus half a second. + # Apply some jitter, take up to at most 25 percent of the retry time. jitter = 1 - 0.25 * random() timeout = sleep_seconds * jitter return timeout if timeout >= 0 else 0 From f4141a2860b3e212053ea830384f89adb098657b Mon Sep 17 00:00:00 2001 From: grayroom Date: Tue, 15 Apr 2025 20:55:00 +0900 Subject: [PATCH 2/2] docs(client): update comment on timeout calculation per review feedback. --- src/openai/_base_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openai/_base_client.py b/src/openai/_base_client.py index 6a5650559d..6dd7f86d8b 100644 --- a/src/openai/_base_client.py +++ b/src/openai/_base_client.py @@ -704,7 +704,7 @@ def _calculate_retry_timeout( # Apply exponential backoff, but not more than the max. sleep_seconds = min(INITIAL_RETRY_DELAY * pow(2.0, nb_retries), MAX_RETRY_DELAY) - # Apply some jitter, take up to at most 25 percent of the retry time. + # Reduce the calculated timeout by a random range between 0-25% jitter = 1 - 0.25 * random() timeout = sleep_seconds * jitter return timeout if timeout >= 0 else 0