0156-python-resilience

Implement tenacity retry wrappers with exponential backoff and jitter for HTTP calls.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/MrJmpl3/codex_____data_____configuration --skill 0156-python-resilience
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: 0156-python-resilience
Source: https://github.com/MrJmpl3/codex_____data_____configuration/tree/main/skills/0156-python-resilience
Command: npx skills add https://github.com/MrJmpl3/codex_____data_____configuration --skill 0156-python-resilience

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It helps developers prevent cascading failures by handling transient errors gracefully instead of immediately failing requests.

Core Features & Use Cases

  • Automatic retries with bounds: Retry only when failures are likely transient, while capping attempts and duration to avoid infinite loops.
  • Exponential backoff with jitter: Space retry attempts safely to reduce load spikes and thundering-herd effects.
  • Timeouts and fault-tolerant decorators: Apply consistent timeout behavior and cross-cutting concerns (like tracing/logging) around business logic.
  • HTTP- and exception-aware retry logic: Retry selected HTTP status codes (e.g., 429/5xx) and specific network exception types.

Quick Start

Tell the AI: implement a retry + exponential backoff (with jitter) wrapper around my external HTTP calls using tenacity, retrying only transient network failures and retryable status codes, with a strict timeout and bounded retry limits.

Frequently Asked Questions about 0156-python-resilience

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement retry logic with exponential backoff in Python to handle transient network failures?

Retry logic with exponential backoff in Python mitigates transient network failures by automatically retrying unsafe requests. Using tenacity-style strategies, it applies bounded retry limits and jitter to space attempts safely, preventing thundering-herd effects on unreliable dependencies.

What's the best way to retry specific HTTP status codes like 429 or 5xx in Python services?

Retrying specific HTTP status codes like 429 or 5xx in Python services requires HTTP-aware exception whitelisting. You configure fault-tolerant decorators to identify transient errors, ensuring only retryable status codes and network exception types trigger another attempt while permanent failures immediately degrade gracefully.

How do you stop infinite retry loops when building fault-tolerant Python decorators?

To stop infinite retry loops in fault-tolerant Python decorators, you apply bounded stop conditions. These strict caps limit maximum attempt counts and total duration, ensuring external HTTP calls eventually fail safely and degrade gracefully instead of continuously hammering rate-limited endpoints.

Can I use tenacity to add timeouts and tracing around my microservice integrations?

Yes, you can use tenacity to add timeouts and tracing around microservice integrations. It applies fault-tolerant decorators as cross-cutting behaviors, wrapping business logic with consistent timeout behavior, logging, and tracing while applying exponential backoff plus jitter for resilient services.

Why do my Python services experience cascading failures when external dependencies become unreliable?

Python services experience cascading failures when external dependencies become unreliable because requests fail immediately without handling transient errors. Implementing automatic retries with exponential backoff and jitter prevents these cascading failures by mitigating transient errors gracefully instead of instantly aborting network calls.

When should I not use automatic retry strategies for network calls in Python?

You should not use automatic retry strategies for network calls in Python when failures are permanent rather than transient. Retrying non-retryable exceptions or unwhitelisted HTTP status codes wastes resources, so you must configure strict exception whitelisting to avoid masking critical application failures.