wshobson avatar

Python Resilience

Built around the tenacity library, this gives you production-ready retry patterns with exponential backoff, jitter, and proper error classification. It shows how to retry network timeouts but not authentication errors, stack timeout decorators with retry logic, and log retry attempts for debugging. The patterns handle both exceptions and HTTP status codes, with examples for synchronous and async code. Good for microservices that call flaky external APIs or any system where you need graceful degradation instead of immediate failures.

skills.sh installs
12.2K
GitHub stars
42.4K
last updated
Aug 21, 2026

Install

$ npx -y skills add wshobson/agents --skill python-resilience --agent claude-code

Installs into .claude/skills of the current project.

Files

Python Resilience Patterns

Build fault-tolerant Python applications that gracefully handle transient failures, network issues, and service outages. Resilience patterns keep systems running when dependencies are unreliable.

When to Use This Skill

  • Adding retry logic to external service calls
  • Implementing timeouts for network operations
  • Building fault-tolerant microservices
  • Handling rate limiting and backpressure
  • Creating infrastructure decorators
  • Designing circuit breakers

Core Concepts

1. Transient vs Permanent Failures

Retry transient errors (network timeouts, temporary service issues). Don't retry permanent errors (invalid credentials, bad requests).

2. Exponential Backoff

Increase wait time between retries to avoid overwhelming recovering services.

3. Jitter

Add randomness to backoff to prevent thundering herd when many clients retry simultaneously.

4. Bounded Retries

Cap both attempt count and total duration to prevent infinite retry loops.

Quick Start

from tenacity import retry, stop_after_attempt, wait_exponential_jitter

Sponsors

Details

Repository
github.com/wshobson/agents
Category
Python

More from wshobson/agents

All 174

Recommended

More Python
1wshobson avatarpython-observabilitywshobson/agentsPython observability patterns including structured logging, metrics, and distributed tracing. Use when adding logging, implementing metrics collection, setting 12Kskills.sh installs
2wshobson avatarpython-resource-managementwshobson/agentsPython resource management with context managers, cleanup patterns, and streaming. Use when managing connections, file handles, implementing cleanup logic, or b11.4Kskills.sh installs
3github avatarpython-mcp-server-generatorgithub/awesome-copilotGenerate a complete MCP server project in Python with tools, resources, and proper configuration10.5Kskills.sh installs
4github avatardataverse-python-production-codegithub/awesome-copilotGenerate production-ready Python code using Dataverse SDK with error handling, optimization, and best practices9.8Kskills.sh installs
5github avatardataverse-python-advanced-patternsgithub/awesome-copilotGenerate production code for Dataverse SDK using advanced patterns, error handling, and optimization techniques.9.2Kskills.sh installs
6github avatardataverse-python-quickstartgithub/awesome-copilotGenerate Python SDK setup + CRUD + bulk + paging snippets using official patterns.8.7Kskills.sh installs