Skip to content

Commit

Permalink
docs: add formula to motivation, too
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek committed Oct 21, 2023
1 parent d5a63b5 commit 977120d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion docs/motivation.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,14 @@ You start with a small backoff and increase it exponentially, adding a random ji
That's what *stamina* does by default:
It starts with 100ms and increases exponentially by 2 until it reaches 45 seconds or 10 attempts.
A jitter between 0 and 1 second is added at every step.
Or, more formally:

That means the first backoff is no longer than 1.1 seconds, and the last is no longer than 46 seconds.
% keep in-sync with stamina.retry's docstring
```{math}
wait\_initial * wait\_exp\_base^{attempt - 1} + random(0, wait\_jitter)
```

That means that, by default, the first backoff is no longer than 1.1 seconds, and the last is no longer than 46 seconds.
You can [tune all these parameters](stamina.retry) to your liking, but the defaults are a good starting point.

---
Expand Down
1 change: 1 addition & 0 deletions src/stamina/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ def retry(
The backoff for retry attempt number *attempt* is computed as:
.. keep in-sync with docs/motivation.md
.. math::
wait\_initial * wait\_exp\_base^{attempt - 1} + random(0, wait\_jitter)
Expand Down

0 comments on commit 977120d

Please sign in to comment.