Metadata-Version: 2.4
Name: ezretry-asik
Version: 0.1.0
Summary: A lightweight, beginner-friendly Python retry decorator with exponential backoff.
Author-email: Your Name <your.email@example.com>
License: MIT
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.7
Description-Content-Type: text/markdown

# ezretry 🔁

A lightweight, beginner-friendly Python decorator to automatically retry failing functions with exponential backoff.

---

## Features

- 🔁 **Simple Decorator Syntax:** Just add `@retry` to any function.
- 📈 **Exponential Backoff:** Configurable backoff multiplier to wait longer between retries.
- 🎯 **Targeted Exceptions:** Catch specific errors and let other bugs crash normally.
- 📝 **Preserved Signatures:** Retains name, docstring, and arguments using `functools.wraps`.
- 🪶 **Zero Dependencies:** Pure Python, standard library only.

---

## Installation

Install locally for development:

```bash
pip install -e .
```

---

## Usage

### Basic Example (Retry on any error)
```python
from ezretry import retry

@retry(tries=3)
def fetch_data():
    print("Trying to fetch...")
    # This will be retried up to 3 times if it fails
    return get_api_data()
```

### Advanced Example (Exponential backoff & logging)
```python
import logging
from ezretry import retry

# Set up logging to see retry warnings
logging.basicConfig(level=logging.INFO)
my_logger = logging.getLogger("app")

# Retries up to 5 times.
# Wait times: 1.0s, 2.0s, 4.0s, 8.0s...
@retry(
    exceptions=(ConnectionError, TimeoutError),
    tries=5,
    delay=1.0,
    backoff=2.0,
    logger=my_logger
)
def upload_data():
    print("Uploading...")
    raise ConnectionError("Server unavailable")
```

---

## Parameters

| Parameter | Type | Default | Description |
| :--- | :--- | :--- | :--- |
| `exceptions` | `Exception` or `tuple` | `Exception` | The exception types to catch and retry on. |
| `tries` | `int` | `3` | Maximum number of attempts (must be $\ge 1$). |
| `delay` | `float` | `1.0` | Initial delay between retries in seconds. |
| `backoff` | `float` | `2.0` | Multiplier applied to the delay after each failure. |
| `logger` | `logging.Logger` | `None` | Optional logger to print warnings before sleeping. |
