EasyReliabilityPython 3

Retry Backoff Planner

Plan retry delays with capped exponential backoff and explicit retryable error classes.

25m2 sample tests3 hidden tests

Implement deterministic retry-delay logic for transient failures.

Requirements

  • Define RetryPolicy(max_attempts, base_delay, max_delay, retryable_errors).
  • next_delay(attempt, error_code) returns the delay before the next try.
  • attempt is the failed attempt number, starting at 1.
  • Return None if the error is not retryable.
  • Return None if attempt >= max_attempts.
  • Otherwise return exponential backoff: base_delay * 2 ** (attempt - 1).
  • Cap the delay at max_delay.

Example

python
1policy = RetryPolicy(4, 0.5, 5, {"timeout"}) 2assert policy.next_delay(1, "timeout") == 0.5 3assert policy.next_delay(4, "timeout") is None

Constraints

  • Do not use randomness.
  • Keep decisions deterministic and testable.
  • Treat unknown errors as non-retryable.

Editor
Results
Run sample tests or submit all tests.