Skip to main content

Retrydec - smart, zero-dependency retry decorator for python supporting sync and async functions with jitter.

📦Installation

pip install retrydec

⚡Quick Start

from retrydec import retry

attempts_num = 0


@retry(attempts=5, delay=0.3)
def example():
    # ↓ Your custom code goes here
    global attempts_num
    attempts_num += 1
    if attempts_num == 3:
        raise TimeoutError("Error: 504") 

✨Retrydec Features

  • No dependencies
  • Smart supporting sync and async functions with jitter
  • Very easy to use
  • Exponential backoff algorithm
  • Custom exception filtering

📃Usage

Library import:

from retrydec import retry

Initialize and run retry decorator with sync or async functions:

@retry()

Decorator arguments

Parameter Type Default Description
attempts int 1 Maximumu numbers of execution attempts.
delay float 1.0 Base delay between attempts in seconds.
exceptions tuple (Exception) Tuple of exceptions to catch and retry.
jitter bool False Enables random noise to prevent server stampede.

Note: all decorator arguments work the same way for both async and sync functions.

Base example:

from retrydec import retry
import asyncio

attempts_num = 0
print("----------Sync test----------")


@retry(attempts=5, delay=0.3)
def example():
    global attempts_num
    attempts_num += 1
    print(f"Attempt number: {attempts_num}")
    raise TimeoutError("Error: 504")  # Server error simulation


try:
    example()
except TimeoutError:
    print("Sync test: OK!")
attempts_num = 0
print("----------Async test----------")


@retry(jitter=True, exceptions=(TimeoutError))
async def example():
    global attempts_num
    attempts_num += 1
    print(f"Attempt number: {attempts_num}")
    if attempts_num == 1:
        raise TimeoutError("Error: 504")  # Server error simulation


asyncio.run(example())
print("Async test: OK!")

❔Why is it convenient?

  • Clean code It replaces the cumbersome try-except-while constructs with a single decorator.
  • Unified API There is no need to support different tools - retrydec uses a single smart decorator that determines whether a function is sync or async.
  • Zero dependencies Provides light weight
  • Safety The built-in backoff and jitter protect your servers from overload during failures.

👦🏻 About the developer

My name is Andrey Egupov, I'm 12 years old. I've been programming for several years. I started in Scratch, now I write in Python, JavaScript, and I'm working with Arduino. The idea for this project came from a desire to create something that would greatly help developers and fill a gap in the Python ecosystem.

📄 License

MIT © 2026 Andrey Egupov

Download files

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

Source Distribution

retrydec-0.1.0.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

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

retrydec-0.1.0-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: retrydec-0.1.0.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.0

File hashes

Hashes for retrydec-0.1.0.tar.gz
Algorithm Hash digest
SHA256 16bff8cf9524e805596a3b92b18bdedb71fd67876dda6f838176f5e3744b558a
MD5 f8af29429c1f31e13c59ea757cae6cff
BLAKE2b-256 08934610498b31ab502795490078724ad3995fea752d573ea8a6699eab5f9b0f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: retrydec-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.0

File hashes

Hashes for retrydec-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c299fa106a11dfb5f5d6d82f70aa0d422630a10f494c919ebdcd9fa8573c2840
MD5 084a5c42a7c575d0fa41b965a5220520
BLAKE2b-256 4974001c28e266860f88cab2e01344b5e6b0c39f5fa7026596de8029f29719a7

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Supported by

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