Skip to main content

eth_retry

Stop transient errors from wasting your time!

eth_retry is a Python library that provides one decorator, eth_retry.auto_retry.

auto_retry will automatically catch known transient exceptions that are common in the Ethereum/EVM ecosystem and will reattempt to evaluate your decorated function up to os.environ['MAX_RETRIES'] (default: 10) times.

Supports both synchronous and asynchronous functions.


Covers many common transient errors in the EVM ecosystem, including:

  • RPC timeouts
  • Block explorer API rate-limiting
  • Generic exceptions:
    • ConnectionError
    • HTTPError
    • ReadTimeout
    • TimeoutError
  • eth-brownie specific errors:
    • sqlite3.OperationalError: database is locked

Installation:

pip install eth_retry or pip install git+https://github.com/BobTheBuidler/eth_retry.git

Usage:

import eth_retry

@eth_retry.auto_retry
def some_function_that_errors_sometimes():
    i = 0
    am = 1
    doing = 2
    stuff = 3
    return stuff

error_free_result = some_function_that_errors_sometimes()

Between attempts, eth_retry will time.sleep for a random period between os.environ['MIN_SLEEP_TIME'] (default: 10) and os.environ['MAX_SLEEP_TIME'] (default: 20) seconds. The period is randomized to help prevent repetitive rate-limiting issues with parallelism by staggering the retries.

On the nth retry, the sleep period is multiplied by n so that the target endpoint can cool off in case of rate-limiting.

After os.environ['MAX_RETRIES'] failures, eth_retry will raise the exception.

Environment:

# Minimum sleep time in seconds. Integer. Defaults to 10.
MIN_SLEEP_TIME=10

# Maximum sleep time in seconds. Integer. Defaults to 20.
MAX_SLEEP_TIME=20

# Maximum number of times to retry. Integer. Defaults to 10.
MAX_RETRIES=10

Metadata

Release files for eth-retry 0.3.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for eth-retry 0.3.8
File Size Uploaded
eth_retry-0.3.8.tar.gz 5.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for eth-retry 0.3.8
File Interpreter ABI Platform
eth_retry-0.3.8-py3-none-any.whl Python 3 none any Details

Total release size: 11.9 kB

Release files / eth_retry-0.3.8.tar.gz

Download URL eth_retry-0.3.8.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
53fba6afd2b89f4450d1f4c0e6cd929d33bd88f3bbf3225526f56db299530f3f
BLAKE2b-256 checksum
How to use checksums
4e9af5fcd9f3ab43428dbe70e189785d2858e4df1b0aea7d61b5759ab61d9cea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.14.6 Linux/6.17.0-1020-azure

Release files / eth_retry-0.3.8-py3-none-any.whl

Download URL eth_retry-0.3.8-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5d1e188cddf2a1ec106faad57cb42d98694a21cea3e6fe3ca44c1fb37ff4f0c6
BLAKE2b-256 checksum
How to use checksums
5968bc63b2081cede3dcc7421c42ee073df8376605161b70704e1432624ab142
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.14.6 Linux/6.17.0-1020-azure

Release history Release notifications | RSS feed

This release

0.3.8 This release

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.20

2 release files

0.1.18

2 release files

0.1.15

2 release files

0.1.14

2 release files

0.1.13

2 release files

0.1.12

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page