Skip to main content

Add your description here

Project description

Retry After

A lightweight, dependency-free Python decorator to automatically handle HTTP 429 Rate Limits and respect Retry-After headers. Built for modern APIs, web scrapers etc, supporting both sync and async clients.

Table of contents

Quick Start

Synchronous Client

import httpx
from retryafter import auto_retry

@auto_retry(max_attempts=3, default_wait=2.0)
def fetch_api_data(url: str) -> dict:
    response = httpx.get(url)
    response.raise_for_status()  # This triggers the retry logic on 429
    return response.json()

Asynchronous Client

import httpx
import anyio
from retryafter import auto_retry

@auto_retry(max_attempts=5)
async def fetch_api_data_async(url: str) -> dict:
    async with httpx.AsyncClient() as client:
        response = await client.get(url)
        response.raise_for_status()
        return response.json()

Configuration

You can customize the decorator behavior using the following parameters:

Parameter Type Default Description
max_attempts int 3 The maximum number of attempts before raising the original exception.
default_wait float 2.0 Fallback wait time (in seconds) if the server does not return a Retry-After header.
reraise bool True If True, bubbles up the original httpx.HTTPStatusError instead of tenacity's RetryError.

License

MIT License © 2026 Dawid Wielechowski

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

retryafter-0.1.0.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

retryafter-0.1.0-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file retryafter-0.1.0.tar.gz.

File metadata

  • Download URL: retryafter-0.1.0.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for retryafter-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4734797410d98982668d5ff46b2895c43e7ba5acb99d653c6a55dcc633aaff91
MD5 8f21dd2ec1959d118a2206ab3408fd95
BLAKE2b-256 eccc2a95636a7895ff725e34b1ae95ab3b9970c9cb9dd8e91dd505555cb02886

See more details on using hashes here.

File details

Details for the file retryafter-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: retryafter-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for retryafter-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 491d47433070246ed708542bd3926470d42ed0dc3da66bbe76a4cf0338eeabe1
MD5 3b815a1c9ef1d214f92651a9e96b744a
BLAKE2b-256 2f444cbb7d0632df071ab08bdd4d9d2aede550f706148c50e91a0eb996ebedfd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page