Skip to main content

Drop-in replacement for tenacity with a Rust core. Same API, faster retries.

Project description

tenacity-rs

CI License: MIT

A drop-in replacement for tenacity with a Rust core. Same API, faster retry engine.

  • API-compatible with tenacity — swap the package and your code keeps working.
  • Faster for retry logic (stop/wait/retry checks); see Benchmarks.
  • Async supported via the same decorator and iterator patterns.

Install

pip install tenacity-rs

Drop-in replacement

pip uninstall tenacity
pip install tenacity-rs

Your existing code works without changes (import stays tenacity_rs or you can alias).
→ See MIGRATION.md for a step-by-step guide and any API differences.

Usage

from tenacity_rs import retry, stop_after_attempt, wait_exponential

@retry(stop=stop_after_attempt(3), wait=wait_exponential(multiplier=1, min=4, max=10))
def call_flaky_service():
    ...

API matches tenacity: @retry, stop_after_attempt, stop_after_delay, wait_fixed, wait_exponential, retry_if_exception_type, retry_if_result, callbacks (before, after, before_sleep), and the iterator pattern (for attempt in Retrying(...)).

Benchmarks

We provide a benchmark suite comparing tenacity-rs with pure-Python tenacity:

pip install -e . tenacity
cd benchmarks && python bench.py

See benchmarks/README.md for options (--iterations, --json, --markdown) and how to interpret results. In short: tenacity-rs is typically 2–5× faster on retry logic; when most time is spent in sleep(), both are similar.

Build from source

Requires Rust and a Python environment.

pip install maturin
maturin develop

For Python 3.13+, set before building:

export PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1
maturin develop

Development

pip install -e ".[test]"
pytest tests/ -v

See CONTRIBUTING.md for guidelines and CODE_OF_CONDUCT.md for community standards.

License

MIT.

Acknowledgments

  • tenacity by Julien Danjou and contributors — API and design. tenacity is licensed under the Apache License, Version 2.0. This project is an independent reimplementation; no code from tenacity has been copied.
  • Built with PyO3 and maturin.

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

tenacity_rs-0.1.0.tar.gz (35.5 kB view details)

Uploaded Source

Built Distributions

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

tenacity_rs-0.1.0-cp312-cp312-win_amd64.whl (212.5 kB view details)

Uploaded CPython 3.12Windows x86-64

tenacity_rs-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (361.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

tenacity_rs-0.1.0-cp312-cp312-macosx_11_0_arm64.whl (317.2 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

tenacity_rs-0.1.0-cp312-cp312-macosx_10_12_x86_64.whl (317.2 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: tenacity_rs-0.1.0.tar.gz
  • Upload date:
  • Size: 35.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tenacity_rs-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f0c1eb37014ad8abab5b9f6c17791ab3ffda8cdce6e2debefe6523e256934dd0
MD5 91028403f494e7f417b891d2086c36e4
BLAKE2b-256 ba621843e1622cf27c9c21675dedd2fc365a8bc3e964421a6ea4f367c9e5bcd9

See more details on using hashes here.

Provenance

The following attestation bundles were made for tenacity_rs-0.1.0.tar.gz:

Publisher: release.yml on wkargul/tenacity-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tenacity_rs-0.1.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: tenacity_rs-0.1.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 212.5 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tenacity_rs-0.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ea5719aa7bc1e5a7b2775f17e24425894de0db52045c046c1fd499a95280f507
MD5 2c1809bae6726e9e2766622457159ede
BLAKE2b-256 2b14d252a14a4ea1a6cf5a446323d2dfc3cfbd62af810d9e32954a9d8d824fc4

See more details on using hashes here.

Provenance

The following attestation bundles were made for tenacity_rs-0.1.0-cp312-cp312-win_amd64.whl:

Publisher: release.yml on wkargul/tenacity-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tenacity_rs-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tenacity_rs-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6a40c7bb142e0b40ddf343d2da7cfa11b7030a32579bed4375ce017f3988d7c8
MD5 b0a2baaca01ad502ecee98fe9540005b
BLAKE2b-256 5fa2352907b4561e2afe7da7aeb05d5f42c67272ee6e4cc5185285d37be50f2e

See more details on using hashes here.

Provenance

The following attestation bundles were made for tenacity_rs-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on wkargul/tenacity-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tenacity_rs-0.1.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tenacity_rs-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fd0efa693e22dac163ba0802d37785639ac9baf9ac045b97af8fb7eb588b7e34
MD5 8480b33a06bc9bc7e4f89789d3872ec1
BLAKE2b-256 1ad82477ff6845e5679a7daf99643b2ed46e22af4e3bcb9db80b1f5c729e782c

See more details on using hashes here.

Provenance

The following attestation bundles were made for tenacity_rs-0.1.0-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: release.yml on wkargul/tenacity-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tenacity_rs-0.1.0-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for tenacity_rs-0.1.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a22020539e307a02860419879e72bf9c9ac350451dc3d5cb735fc4059a52911a
MD5 1415c3aae93fbd0e25a978458e9ece9a
BLAKE2b-256 5a91632fbde6547590b5b5e295748ba3bd3a14da770465c1f493b722dc654f0d

See more details on using hashes here.

Provenance

The following attestation bundles were made for tenacity_rs-0.1.0-cp312-cp312-macosx_10_12_x86_64.whl:

Publisher: release.yml on wkargul/tenacity-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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