Skip to main content

Well-featured retry decorator

Project description

From the Jargon File:

The -P Convention

Turning a word into a question by appending the syllable ‘P’;
from the LISP convention of appending the letter ‘P’ to denote
a predicate (a boolean-valued function). The question should
expect a yes/no answer, though it needn't. (See T and NIL.)

retryp is yet another retry decorator, with nothing particularly special about it other than it being both well-featured and not rewriting or hiding the calling signature of the wrapped method (allows for accurate code introspection – a Big Deal for me).

Thanks go to Graham Dumpleton and his wrapt package for that latter.

Arguments

backoff

Default: 10

A multiplicative factor applied to the delay, used to provide increasing backoff as subsequent attempts continue to fail.

count

Default: 10

Number of times to retry the wapped item. If set to “0”, will retry 1073741823 times because a) that’s a lot, b) give up already, and c) nothing lasts forever.

delay

Default: 10 (seconds)

The base delay between retry attempts.

expose_last_exc

Default: False

By default retryp will raise retryp.FailedTooOften if the wrapped item continues to fail after the requested number of attempts. If expose_last_exc is set, then the exception raised by the wrapped item will be raised if the last attempt results in an exception.

jitter

Default 0

Extra random seconds will be added to each retry delay, ranging from 0 to the value of jitter.

log_faults

Default: False

Log every exception raised by the wrapped item using logtool.log_fault.

log_faults_level

Default: logging.DEBUG

Logging level at which exceptions will be logged by logtool.log_fault() when log_faults is set.

name

Default: None

String to use in log messages to describe what is being retried.

refuse_rc_fn

Default: None

If provided, the return of the wrapped item will be passed as the only argument to this function. If refuse_rc_fn (rc) evaluates to True, then no further retries will be made.

refuse_exc_fn

Default: None

If provided, any exception raised by the wrapped item will be passed as the only argument to this function. If refuse_exc_fn (e) evaluates to True, then the exception will be raised again and retry attempts will cease.

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

retryp-0.3.post9.tar.gz (23.7 kB view details)

Uploaded Source

File details

Details for the file retryp-0.3.post9.tar.gz.

File metadata

  • Download URL: retryp-0.3.post9.tar.gz
  • Upload date:
  • Size: 23.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for retryp-0.3.post9.tar.gz
Algorithm Hash digest
SHA256 561c4d27cd70f6f5d14caed45c15b2a52cf94f47f1b107037946560755ffa5a6
MD5 79c30b6985112799bac00103d41ffbbe
BLAKE2b-256 b88e2396c5d503fac37df2aaa9cbed7a85d42004c4f3ec3eebe76587793988ea

See more details on using hashes here.

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