Skip to main content

No project description provided

Project description

A simple decorator for retry functions

@retry(ValueError, KeyError,
         retry = True, 
         attempts = 3,
         wait = 1,
         reraise = True,
         logger = logging.debug
         )
def func():
   pass

Decorator parameters

exceptions

SPECIFIED exception types.

retry

if retry is True , retry when the decorated function throws the SPECIFIED exceptions.
if retry is False , retry when the decorated function throws the UNSPECIFIED exceptions.
Default is True.

attempts

The number of retries attempted. Default is 3.

wait

The wait interval between retries (second).
Default is 1 second.

reraise

If reraise is True, when an exception is thrown by the decorated function, that exception will be rethrown. If raraise is False, then None is returned instead.
Default is True.

logger

The logger function will be used when the decorated function raise exception. Default is logging.warning.

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

decorator_retry-0.1.6.tar.gz (1.9 kB view hashes)

Uploaded Source

Built Distribution

decorator_retry-0.1.6-py3-none-any.whl (2.3 kB view hashes)

Uploaded Python 3

Supported by

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