Skip to content

feat: add min param and timedelta support to wait_exponential_jitter#628

Merged
mergify[bot] merged 1 commit intomainfrom
devs/jd/feat/wait-exponential-jitter-multiplier/Ic02ae68b863cc0d1cd5a3b7874006c193c0c14a8
Mar 11, 2026
Merged

feat: add min param and timedelta support to wait_exponential_jitter#628
mergify[bot] merged 1 commit intomainfrom
devs/jd/feat/wait-exponential-jitter-multiplier/Ic02ae68b863cc0d1cd5a3b7874006c193c0c14a8

Conversation

@jd
Copy link
Owner

@jd jd commented Mar 11, 2026

wait_exponential already supports min and timedelta for min/max.
wait_exponential_jitter lacked both, which was an inconsistency users
asked for in #426.

  • Accept timedelta for max, jitter, and min parameters
  • Add min parameter to set a minimum wait time floor
  • Convert all time parameters via _utils.to_seconds() in __init__

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

…tter`

`wait_exponential` already supports `min` and `timedelta` for min/max.
`wait_exponential_jitter` lacked both, which was an inconsistency users
asked for in #426.

- Accept `timedelta` for `max`, `jitter`, and `min` parameters
- Add `min` parameter to set a minimum wait time floor
- Convert all time parameters via `_utils.to_seconds()` in `__init__`

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Change-Id: Ic02ae68b863cc0d1cd5a3b7874006c193c0c14a8
@jd
Copy link
Owner Author

jd commented Mar 11, 2026

This pull request is part of a stack:

  1. feat: add min param and timedelta support to wait_exponential_jitter (#628) 👈
  2. feat: deprecate initial in favor of multiplier in wait_exponential_jitter (#629)

@mergify
Copy link
Contributor

mergify bot commented Mar 11, 2026

⚠️ The sha of the head commit of this PR conflicts with #627. Mergify cannot evaluate rules on this PR. Once #627 is merged or closed, Mergify will resume processing this PR. ⚠️

@jd jd marked this pull request as ready for review March 11, 2026 14:20
Copilot AI review requested due to automatic review settings March 11, 2026 14:20
@mergify mergify bot merged commit 3233040 into main Mar 11, 2026
18 checks passed
@mergify mergify bot deleted the devs/jd/feat/wait-exponential-jitter-multiplier/Ic02ae68b863cc0d1cd5a3b7874006c193c0c14a8 branch March 11, 2026 14:20
@mergify
Copy link
Contributor

mergify bot commented Mar 11, 2026

Merge Queue Status

  • Entered queue2026-03-11 14:20 UTC · Rule: default
  • Checks passed · in-place
  • Merged2026-03-11 14:20 UTC · at 5790144853a0172f75ca5f6b92a6c802026f9742

This pull request spent 6 seconds in the queue, with no time running CI.

Required conditions to merge

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds missing parity between wait_exponential and wait_exponential_jitter by introducing a minimum wait floor and supporting datetime.timedelta inputs for key time parameters.

Changes:

  • Add min parameter to wait_exponential_jitter and apply it as a lower bound on computed waits.
  • Accept timedelta for max, jitter, and min by normalizing via _utils.to_seconds() in __init__.
  • Expand test coverage for the new min behavior and timedelta inputs; add a release note entry.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
tenacity/wait.py Extends wait_exponential_jitter API and clamps waits using the new min floor; normalizes time params via _utils.to_seconds().
tests/test_tenacity.py Adds tests for min floor behavior and timedelta parameter handling.
releasenotes/notes/wait-exponential-jitter-min-timedelta-a8e3c1f4b7d29e50.yaml Documents the new min parameter and timedelta support.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

https://cloud.google.com/storage/docs/retry-strategy

The wait time is min(initial * 2**n + random.uniform(0, jitter), maximum)
The wait time is max(min, min(initial * 2**n + random.uniform(0, jitter), maximum))
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docstring formula hard-codes 2**n, but the implementation uses the configurable exp_base (self.exp_base ** (attempt_number - 1)). The docstring should reflect exp_base**n (or similar) to avoid misleading users who pass a non-default exp_base.

Suggested change
The wait time is max(min, min(initial * 2**n + random.uniform(0, jitter), maximum))
The wait time is max(min, min(initial * exp_base**n + random.uniform(0, jitter), maximum))

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants