resilience-patterns

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

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill provides Python code patterns to make applications resilient to failures in external services, preventing cascading errors and ensuring graceful operation even when dependencies are unavailable.

Core Features & Use Cases

  • Retry with Backoff: Automatically retry failed operations with increasing delays to avoid overwhelming services.
  • Circuit Breaker: Prevent repeated calls to a failing service, failing fast instead of waiting for timeouts.
  • Timeout Wrapper: Enforce maximum execution times for operations to prevent indefinite hangs.
  • Graceful Degradation: Allow applications to continue functioning with reduced capabilities when non-critical services fail.
  • Use Case: When calling a third-party API that is occasionally slow or unavailable, these patterns ensure your application doesn't crash, retries intelligently, and can even provide a degraded experience if the API is down for an extended period.

Quick Start

Use the resilience-patterns skill to implement retry logic with exponential backoff for a function that calls an external API.

Frequently Asked Questions about resilience-patterns

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

FAQPage Schema
How do I implement a circuit breaker in Python to stop calling a failing API?

A circuit breaker in Python prevents repeated calls to a failing service by failing fast instead of waiting for timeouts. This pattern monitors service outages and trips the breaker to halt requests, preventing cascading errors across your application.

What is the best way to retry failed Python functions with exponential backoff?

Retrying failed Python functions with exponential backoff automatically retries operations using increasing delays. This avoids overwhelming an external service during temporary outages, ensuring your application recovers gracefully without causing additional load on the dependency.

How do I enforce a timeout on external API calls in Python to prevent indefinite hangs?

Enforcing a timeout on Python operations limits maximum execution times, preventing indefinite hangs when calling external services. By utilizing standard Python libraries for threading and signals, the timeout wrapper terminates operations that exceed the defined duration.

Can I use standard Python libraries for fault tolerance without external dependencies?

Standard Python libraries fully support fault tolerance without external dependencies. The patterns utilize native threading, signals, and context management to implement resilience mechanisms like circuit breakers and timeouts directly within your application stack.

What is graceful degradation in Python and when should I use it?

Graceful degradation in Python allows applications to continue functioning with reduced capabilities when non-critical services fail. You should use this pattern when a dependency outage would otherwise crash your app, ensuring core features remain operational.

Why does my Python application crash when a third-party API is slow or unavailable?

A Python application crashes when a third-party API is slow because it lacks resilience patterns for handling external service failures. Implementing timeouts, retries, and circuit breakers prevents these cascading errors and ensures graceful operation despite dependency downtime.