Courses/Advanced Deep Dives

๐Ÿ”ฌ Advanced Deep Dives

Retry with Backoff

A production-grade retry decorator.

Wrap a flaky function so it retries on failure. Use functools.wraps to preserve the wrapped function's name and docstring.

@retry(times=3)
def call_api(): ...

Real versions add exponential backoff (time.sleep(base * 2**i)) and exception-type filtering. Pyodide has no real sleep tax, so we just count attempts here.

main.py
Output
Press Run to execute.
Expected output
ok 3

Sign in to track your progress across lessons.