Welcome to the resilience utilities team. This module computes retry backoff delays: for attempts 1..n, base 2(attempt-1), capped at max_delay. policy.delay_for works out the delay for one attempt and backoff.backoff_del…
Welcome to the resilience utilities team. This module computes retry backoff delays: for attempts 1..n, base * 2**(attempt-1), capped at max_delay. policy.delay_for works out the delay for one attempt and backoff.backoff_delays returns the delays for a whole run of attempts.
There is one ticket below. Fix as much of it as you can in 35 minutes. It is graded by several hidden checks, each checked separately, so every part of the behaviour you get right counts.
base * 2**(a-1).max_delay.Backoff delays start too high and grow without bound. The per-attempt delay uses 2**attempt instead of 2**(attempt-1), and max_delay is never applied.
backoff_delays(1, 4, 100) is [1, 2, 4, 8].backoff_delays(1, 5, 5) is [1, 2, 4, 5, 5] (capped at max_delay).backoff_delays(3, 3, 100) is [3, 6, 12].Keep the public function backoff_delays.
policy.py (delay_for, the per-attempt delay) and backoff.py (backoff_delays). The shipped regression tests are in tests/visible/; every one of them fails until the bugs are fixed.pytest tests/visible.Adapted from treasure567/bloomberg-practice (round-1/vesper @ 8de07d5), used with the author's permission.
Visible test command
pytest tests/visibleThe repository’s own tests. Run all tests includes them, and so does every submission.
Repository
retry-backoff-delays-ignore-the-cap
Changes under src/ are evaluated.