@@ -239,17 +239,19 @@ def _calculate_backoff_value(self, retry_count):
239
239
"""
240
240
Calculate the backoff delay for a given retry attempt.
241
241
242
- This method computes an exponential backoff value based on the retry count.
243
- Optionally, it adds a random jitter to introduce variability in the delay
244
- to prevent synchronized retries in distributed systems. The backoff value is
245
- clamped between 0 and a maximum allowed delay (`self.max_backoff_seconds`).
242
+ This method computes an exponential backoff delay based on the retry count and
243
+ a configurable backoff factor. It optionally adds a random jitter to introduce
244
+ variability in the delay, which can help prevent synchronized retries in
245
+ distributed systems. The calculated backoff delay is clamped between 0 and a
246
+ maximum allowable delay (`self.max_backoff_seconds`) to avoid excessively long
247
+ wait times.
246
248
247
249
:param retry_count: int, REQUIRED: The current retry attempt number (1-based).
248
250
Determines the exponential backoff delay.
249
251
:return: float: The calculated backoff delay in seconds, adjusted for jitter
250
252
and clamped to the maximum allowable value.
251
253
"""
252
- backoff_value = 2 ** (retry_count - 1 )
254
+ backoff_value = self . backoff_factor * ( 2 ** (retry_count - 1 ) )
253
255
if self .backoff_jitter != 0.0 :
254
256
backoff_value += random .random () * self .backoff_jitter
255
257
return float (max (0 , min (self .max_backoff_seconds , backoff_value )))
0 commit comments