For first retry compute_backoff
always return value below min_backoff
settings #651
Open
Description
Checklist
- Does your title concisely summarize the problem?
- Did you include a minimal, reproducible example?
- What OS are you using?
- What version of Dramatiq are you using? - 1.17.0
- What did you do?
- What did you expect would happen?
- What happened?
Dramatiq calculate delay time like this:
min_backoff = message.options.get("min_backoff", actor.options.get("min_backoff", self.min_backoff))
max_backoff = message.options.get("max_backoff", actor.options.get("max_backoff", self.max_backoff))
max_backoff = min(max_backoff, DEFAULT_MAX_BACKOFF)
_, delay = compute_backoff(retries, factor=min_backoff, max_backoff=max_backoff)
dramatiq/dramatiq/middleware/retries.py
Line 130 in 3e20bdd
When message retries first time we have a retries = 0
in this scope.
Then compute_backoff
return value always below min_backoff
This happend due default jitter=True
flag in compute_backoff
function
You can check it manually:
from dramatiq.common import compute_backoff
retries = 0
compute_backoff(retries, factor=1000, max_backoff=5000)
Out[4]: (1, 734)
compute_backoff(retries, factor=1000, max_backoff=5000)
Out[5]: (1, 527)
compute_backoff(retries, factor=1000, max_backoff=5000)
Out[6]: (1, 924)
compute_backoff(retries, factor=1000, max_backoff=5000)
Out[7]: (1, 625)
What OS are you using?
macOS 14.4.1
What version of Dramatiq are you using?
1.17.0
What did you do?
Run task with expected delay
What did you expect would happen?
Delay should be between min_backoff and max_backoff
What happened?
Calculated delay below min_backoff
Metadata
Assignees
Labels
No labels