python-resilience

Implement retries, exponential backoff, jitter, and timeouts in Python applications.

38.6k|4.1k|Updated Jul 24, 2025
One-click install
npx skills add https://github.com/wshobson/agents --skill python-resilience-wshobson
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-resilience
Source: https://github.com/wshobson/agents/tree/main/plugins/python-development/skills/python-resilience
Command: npx skills add https://github.com/wshobson/agents --skill python-resilience-wshobson

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill helps developers build robust Python applications that can gracefully handle transient failures, network issues, and service outages, ensuring continuous operation.

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 strict time limits for operations to prevent indefinite hangs.
  • Fault-Tolerant Decorators: Apply resilience patterns easily using decorators.
  • Use Case: When calling a third-party API that occasionally returns 5xx errors or times out, this skill can automatically retry the request a few times with increasing delays, ensuring the operation eventually succeeds or fails predictably.

Quick Start

Use the python-resilience skill to add retry logic with exponential backoff to a function that calls an external API.

Frequently Asked Questions about python-resilience

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

FAQPage Schema
How do I implement automatic retries in Python for external API calls?

Automatic retries in Python use fault-tolerant decorators to re-run failed external API calls. This skill provides code patterns using libraries like tenacity to handle transient failures by automatically retrying requests that return 5xx errors.

What's the best way to add exponential backoff and jitter to Python network requests?

Exponential backoff and jitter prevent overwhelming services by increasing wait times between retries with added randomness. This skill provides Python patterns to implement these resilience techniques, ensuring network requests fail predictably without causing service outages.

How do I set timeouts for Python functions to prevent indefinite hangs?

Timeouts in Python set strict time limits for operations to prevent indefinite hangs. This skill provides patterns using asyncio to implement timeouts, ensuring your application gracefully handles network issues and service outages without blocking indefinitely.

Can I use fault-tolerant decorators with async Python applications?

Fault-tolerant decorators can be applied to async Python applications using asyncio. This skill provides resilience patterns including retry logic, exponential backoff, and timeouts that integrate with async code to build fault-tolerant services.

Why do my Python services fail when calling third-party APIs that occasionally return 5xx errors?

Python services fail on 5xx errors because they lack resilience patterns like automatic retries. This skill solves transient failures by providing decorator-based retry logic with exponential backoff, ensuring operations eventually succeed or fail predictably.

Do I need structlog to implement resilience patterns in Python?

Structlog is used alongside tenacity, httpx, and asyncio in this skill to provide structured logging for resilience patterns. While the core retry and timeout mechanisms work independently, structlog helps monitor retry behavior and track transient failures.