Skip to content

Commit 241f621

Browse files
sophiecuiyclaude
andcommitted
fix: inline backoff computation, remove backoff cap
Drop _compute_backoff helper and inline the logic directly in the retry loop. Remove the 300s backoff cap to preserve the original unbounded exponential behavior. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3191bd1 commit 241f621

1 file changed

Lines changed: 2 additions & 16 deletions

File tree

airbyte_cdk/sources/streams/http/http_client.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -251,21 +251,6 @@ def _max_time(self) -> int:
251251
else self._DEFAULT_MAX_TIME
252252
)
253253

254-
_MAX_BACKOFF_SECONDS: float = 300 # 5-minute ceiling for exponential backoff
255-
256-
def _compute_backoff(self, exc: RetryRequestException, attempt: int) -> float:
257-
"""Compute the backoff duration in seconds for a retry attempt.
258-
259-
If the exception carries a user-defined ``backoff_time``, that value plus
260-
one second is returned (preserving the legacy +1 s behaviour). Otherwise
261-
an exponential back-off of ``2 ** (attempt - 1)`` seconds is used (matching
262-
the previous ``backoff.expo`` with base=2, factor=1), capped at
263-
``_MAX_BACKOFF_SECONDS``.
264-
"""
265-
if exc.backoff_time is not None:
266-
return exc.backoff_time + 1 # extra second to cover fractions
267-
return min(float(2 ** (attempt - 1)), self._MAX_BACKOFF_SECONDS)
268-
269254
def _send_with_retry(
270255
self,
271256
request: requests.PreparedRequest,
@@ -312,7 +297,8 @@ def _send_with_retry(
312297
stream_descriptor=StreamDescriptor(name=self._name),
313298
)
314299

315-
backoff_seconds = self._compute_backoff(exc, attempt)
300+
# User-defined backoff gets +1s to cover fractions; otherwise exponential 2^(n-1)
301+
backoff_seconds = exc.backoff_time + 1 if exc.backoff_time is not None else float(2 ** (attempt - 1))
316302

317303
if exc.response is not None and isinstance(exc.response, requests.Response):
318304
self._logger.info(

0 commit comments

Comments
 (0)