Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing

Retry a flaky operation with a cap

Python data engineering interview problem. Difficulty: intermediate. Pattern: Recursion. About 15 minutes. Part of the Pro drill bank.

A downstream HTTP call flakes. The job retries a few times and then gives up with a defined result, rather than hanging forever.

Retry a flaky operation with a cap and return the first success (or the fallback the tests define).

Requirements

  • Stop at the first success.
  • Do not exceed the provided attempts.

Constraints

  • attempts: a sequence of outcomes (0/1, exceptions, or values).
  • All failures: return the contracted fallback.
  • Zero attempts should be defined.

Examples

Input: retry_until_ok(['__fail__', 9]) Output: 9 This input follows the stated rules and produces this output.

Topics: lakebench, python, error-handling.

More Python interview questions · All interview problems · Learn data engineering

intermediate

Retry a flaky operation with a cap

Interview-style drill: Write a function that retries a failing operation up to a maximum number of attempts before giving up.

Retry a flaky operation with a cap and return the first success (or the fallback the tests define).