Retries interview problems

Retry questions ask you to wrap an unreliable call so transient failures don't reach the caller. Expect to write a decorator or a helper like retry(fn, attempts=5, base_delay=0.1), often for an async function. The pattern is exponential backoff, base * 2 ** attempt, capped at a maximum, with jitter from random.uniform so many clients don't retry in lockstep. The sleep is await asyncio.sleep(delay) in async code, never time.sleep, which blocks the event loop. functools.wraps keeps the wrapped function's name and docstring.

The classic mistakes are retrying every exception, including ValueError from a bug and asyncio.CancelledError from a caller who gave up, sleeping after the final attempt, and swallowing the last error instead of re-raising it. A strong answer takes a tuple of retryable exception types, re-raises the final failure with its traceback intact, and respects an overall deadline as well as a per-attempt count. It also raises idempotency without being asked. Retrying a payment or a non-idempotent POST can do the work twice, so either the operation needs an idempotency key or it should not be retried.

1 open problem

  1. 22Async Retry with Exponential Backoffmedium

    Retry a failing coroutine with capped exponential backoff, re-raise the last error, and never swallow cancellation.

3 locked

These open in order of demand. Open one and press I want this one to ask for it.

  1. 08Retry Scheduler with Exponential Backoff Lockedhard

    Build a request scheduler that retries failures with exponential backoff, orders work by ready time and tracks a five-state lifecycle.

  2. 10Async Inference with Retries and Timeouts Lockedhard

    Run async inference calls under a concurrency cap with a per-attempt timeout, bounded retries, attempt counts and correct cancellation.

  3. 42Chunked Upload with Retries Lockedmedium

    Upload a large file in fixed-size chunks through an async send function, retrying each chunk independently and never loading the whole file.