python-resilience

Implement retry, timeout, and circuit breaker patterns in Python.

2|Updated Mar 15, 2025
One-click install
npx skills add https://github.com/dandudzi/dotfiles --skill python-resilience-dandudzi
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-resilience
Source: https://github.com/dandudzi/dotfiles/tree/main/dot_claude/skills/python-resilience
Command: npx skills add https://github.com/dandudzi/dotfiles --skill python-resilience-dandudzi

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires tenacity, httpx, asyncio, logging, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill helps developers build resilient Python applications that can gracefully handle transient failures, network issues, and service outages, preventing application crashes and ensuring a better user experience.

Core Features & Use Cases

  • Retry Strategies: Implement automatic retries for operations that might fail temporarily (e.g., network errors, temporary service unavailability).
  • Timeouts: Prevent operations from hanging indefinitely by setting strict time limits.
  • Circuit Breakers: Protect your system from cascading failures by temporarily stopping calls to an unhealthy service.
  • Graceful Degradation: Provide fallback mechanisms (e.g., cached data, default values) when primary services are unavailable.
  • Use Case: When calling an external API that is sometimes slow or returns temporary errors, this Skill can automatically retry the call with increasing delays, or fall back to cached data if the API remains unresponsive, ensuring your application continues to function.

Quick Start

Use the python-resilience skill to fetch data from 'https://api.example.com/data' with retries and a 30-second timeout.

Frequently Asked Questions about python-resilience

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

FAQPage Schema
How do I implement a circuit breaker in Python to prevent cascading failures?

A circuit breaker in Python prevents cascading failures by temporarily stopping calls to an unhealthy service. This Skill provides code patterns to implement this mechanism, ensuring your distributed system degrades gracefully during outages.

What is the best way to handle transient errors and network timeouts in Python applications?

Handling transient errors and network timeouts in Python requires retry mechanisms with exponential backoff and strict time limits. This Skill implements these strategies to prevent operations from hanging indefinitely during flaky network conditions.

How do I add exponential backoff and jitter to Python retry logic?

Adding exponential backoff and jitter to Python retry logic involves increasing delays between subsequent attempts with randomized variation. This Skill provides specific code patterns using the tenacity library to automate this fault tolerance strategy.

Does this Python fault tolerance approach work with asynchronous operations?

Yes, this Python fault tolerance approach supports asynchronous operations. It leverages the asyncio library to implement retry strategies, timeout handling, and circuit breaker patterns for non-blocking network requests.

How do I implement graceful degradation when an external API is unresponsive?

Graceful degradation when an external API is unresponsive is implemented by falling back to cached data or default values. This Skill provides fallback mechanisms to ensure your application continues to function despite primary service failures.

When should I not use a circuit breaker pattern in Python?

You should avoid using a circuit breaker pattern in Python for non-idempotent operations where retries are unsafe, or when external service failures require immediate hard crashes rather than graceful degradation. It is best suited for transient network errors.