python-resilience

Implement retries, exponential backoff, jitter, and timeouts using tenacity.

Updated Mar 5, 2026
One-click install
npx skills add https://github.com/Himanshu040604/codex-skills-setup --skill python-resilience-himanshu040604
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-resilience
Source: https://github.com/Himanshu040604/codex-skills-setup/tree/main/assets/codex/skills/claude-import/skills/plugins/python-development%40claude-code-workflows/skills/python-resilience
Command: npx skills add https://github.com/Himanshu040604/codex-skills-setup --skill python-resilience-himanshu040604

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires tenacity, httpx, structlog, asyncio.

What problem does it solve?

This Skill helps developers build fault-tolerant Python applications that can gracefully handle transient failures, network issues, and service outages, ensuring system reliability.

Core Features & Use Cases

  • Automatic Retries: Implement retry logic for external service calls that may fail temporarily.
  • Exponential Backoff & Jitter: Prevent overwhelming services by increasing wait times between retries with added randomness.
  • Timeouts: Set explicit timeouts for network operations to prevent indefinite hangs.
  • Fault-Tolerant Services: Design microservices that can withstand temporary dependency failures.

Quick Start

Use the python-resilience skill to add retry logic with exponential backoff to the call_external_service function, retrying up to 3 times with a maximum 10-second wait between attempts.

Frequently Asked Questions about python-resilience

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

FAQPage Schema
How do I add retry logic to Python functions calling external services?

Retry logic for external service calls in Python is handled automatically using the tenacity library, which allows you to configure functions to retry transient failures up to a specified number of attempts before failing.

What is exponential backoff with jitter and when do I need it for Python fault tolerance?

Exponential backoff with jitter is a resilience pattern that increases wait times between retries with added randomness to prevent overwhelming recovering services, needed when handling network issues or service outages in distributed systems.

How do I set network operation timeouts in Python to prevent indefinite hangs?

Network operation timeouts in Python are set explicitly using httpx and asyncio dependencies to define strict maximum durations for external calls, ensuring operations fail fast instead of hanging indefinitely during outages.

Does this resilience approach work with asynchronous Python microservices?

Yes, the resilience patterns utilize asyncio to support asynchronous Python microservices, allowing them to implement automatic retries, exponential backoff, and timeouts for graceful degradation during temporary dependency failures.

Why do my Python retries keep overwhelming the target service instead of recovering gracefully?

Retries overwhelm target services when lacking exponential backoff and jitter; applying these resilience patterns increases wait times with randomness between attempts, preventing synchronized retry storms during outages.

Do I need structlog to implement fault-tolerant Python applications?

Structlog is utilized within this resilience approach to provide structured logging for error handling and retry events, giving developers visibility into transient failures and graceful degradation processes.