python.unbounded_retry
Stability
High
Causes Production Outages
Detects retry patterns (tenacity, backoff, custom loops) that don’t have proper bounds, which can cause infinite loops on permanent failures.
Why It Matters
Section titled “Why It Matters”Unbounded retries create two serious problems:
- Infinite loops — When a downstream service is permanently down, retries loop forever
- Cascade failures — Retries pile up, exhausting your resources and DoS-ing the already-struggling downstream
During an outage, unbounded retries make recovery harder. The system needs breathing room, not more pressure.
Example
Section titled “Example”# ❌ Before (unbounded)from tenacity import retry
@retry()def fetch_data(): return requests.get(url)This will retry forever if url is permanently unreachable.
# ✅ After (bounded)from tenacity import retry, stop_after_attempt, wait_exponential
@retry( stop=stop_after_attempt(3), wait=wait_exponential(multiplier=1, min=1, max=10))def fetch_data(): return requests.get(url)Three attempts with exponential backoff. Fails fast after that.
What Unfault Detects
Section titled “What Unfault Detects”@retry()withoutstopparameter@retrywithoutstop_after_attemptorstop_after_delay@backoff.on_exception()withoutmax_trieswhile Trueretry loops without break conditions
Auto-Fix
Section titled “Auto-Fix”Unfault can add stop=stop_after_attempt(3) and wait=wait_exponential() to retry decorators when the pattern is recognized.