Skip to main content

PyPi Version Travis Test Status

A simple way to auto retry a funciton that has the possibility of raising an error. You can either call retry directly or decorate a function to get it to retry. Intelligent matching logic allows you to retry certain exception while raising other exceptions.

Call a function directly:

from retrypy import retry, check

def dummy_func():
    print "dummy_func called..."
    raise Exception("House")

retry.call(
    dummy_func,
    times=2
)

dummy_func called...
dummy_func called...
Exception: House

# usign a check method
retry.call(
    dummy_func,
    check = check.message_equals("foobar")
)
dummy_func called...
Exception: House

Decorating a function:

# Only retry IOErrors
@retry.decorate(IOError, times=2)
def dummy_func():
    print "dummy_func called..."
    raise IOError("House")
dummy_func()

dummy_func called...
dummy_func called...
IOError: House

# Retry any Exception, use a custom wait function
@retry.decorate(times=2, wait=lambda n: 2*n)
def dummy_func():
    print "dummy_func called..."
    raise Exception("House")
dummy_func()

dummy_func called...
dummy_func called...
Exception: House

Wrap a function and retrun a new callable:

def dummy_func():
    print "dummy_func called..."
    raise Exception("House")

func = retry.wrap(
    dummy_func,
    times=2
)
func()

dummy_func called...
dummy_func called...
Exception: House

Installation:

>> pip install retrypy

Development:

>> git clone https://github.com/toddsifleet/retrypy
>> cd retrypy
>> make bootstrap
>> make

License:

See LICENSE

Metadata

Release files for retrypy 0.0.31

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

Source distribution (sdist)

Source distribution for retrypy 0.0.31
File Size Uploaded
retrypy-0.0.31.tar.gz 3.6 kB Details

Release files / retrypy-0.0.31.tar.gz

Download URL retrypy-0.0.31.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
bfe43c756a8ff4bddb0b7c7681a99d495193f762f57872c3dc4c873a9c944acc
BLAKE2b-256 checksum
How to use checksums
aae022ea807d034cf0ba7d458bbab98f1be829f0f80c73ed138f712b7cb6da2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.0.33

1 release file

0.0.32

1 release file

This release

0.0.31 This release

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

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