Skip to content

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.

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.

# ❌ 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.

  • @retry() without stop parameter
  • @retry without stop_after_attempt or stop_after_delay
  • @backoff.on_exception() without max_tries
  • while True retry loops without break conditions

Unfault can add stop=stop_after_attempt(3) and wait=wait_exponential() to retry decorators when the pattern is recognized.