python-resilience

Implement retries, exponential backoff with jitter, and timeouts in Python using tenacity and httpx.

2|Updated Feb 5, 2026
One-click install
npx skills add https://github.com/yashvinthan/DuskSpendr --skill python-resilience-yashvinthan
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-resilience
Source: https://github.com/yashvinthan/DuskSpendr/tree/main/.agents/skills/python-resilience
Command: npx skills add https://github.com/yashvinthan/DuskSpendr --skill python-resilience-yashvinthan

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill helps developers build more reliable Python applications by implementing patterns that gracefully handle transient failures, network issues, and service outages.

Core Features & Use Cases

  • Automatic Retries: Implement retry logic for external service calls that may fail temporarily.
  • Exponential Backoff & Jitter: Prevent overwhelming services during recovery and avoid thundering herd issues.
  • Timeouts: Ensure operations don't hang indefinitely, improving application responsiveness.
  • Fault-Tolerant Decorators: Apply resilience patterns consistently across different functions.
  • Use Case: When making an API call that occasionally times out, use this Skill to automatically retry the call a few times with increasing delays before giving up.

Quick Start

Use the python-resilience skill to define a function that retries a network call up to 3 times with exponential backoff and jitter.

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 for Python network calls?

Automatic retries for Python network calls are implemented using fault-tolerant decorators that re-execute failed functions. This Skill applies retry logic to external service calls, ensuring transient errors trigger repeated attempts before giving up.

What is exponential backoff with jitter and when do I need it?

Exponential backoff with jitter progressively increases delays between retry attempts while adding randomization. You need this resilience pattern to prevent overwhelming recovering services and to avoid thundering herd issues during network outages.

How do I add timeouts to Python functions to prevent hanging?

Timeouts prevent Python functions from hanging indefinitely by capping execution duration. This Skill provides code patterns to ensure operations respect time limits, improving application responsiveness under unreliable network conditions.

Does this resilience approach work with asyncio and httpx?

Yes, the resilience patterns support asyncio and httpx for robust error handling. These dependencies are integrated to provide asynchronous retry mechanisms and reliable HTTP client operations during transient failures.

What's the best way to handle transient errors in Python services?

The best way to handle transient errors in Python services combines automatic retries, exponential backoff, and timeouts. Applying fault-tolerant decorators consistently across functions ensures application stability when facing unreliable network conditions.

Why should I use tenacity for retry logic instead of custom loops?

Tenacity provides mature retry mechanisms with built-in exponential backoff and jitter, avoiding custom loop complexities. It integrates with structlog for logging, delivering robust fault tolerance without reinventing error handling logic.