pyramid_retry
API¶
- pyramid_retry.includeme(config)[source]¶
Activate the
pyramid_retry
execution policy in your application.This will add the
pyramid_retry.RetryableErrorPolicy()
withattempts
pulled from theretry.attempts
setting.The
last_retry_attempt
andretryable_error
view predicates are registered.This should be included in your Pyramid application via
config.include('pyramid_retry')
.
- pyramid_retry.RetryableExecutionPolicy(attempts=3, activate_hook=None)[source]¶
Create a execution policy that catches any retryable error and sends it through the pipeline again up to a maximum of
attempts
attempts.If
activate_hook
is set it will be consulted prior to each request to determine if retries should be enabled. It should return a number > 0 of attempts to be used orNone
which will indicate to use the default number of attempts.
- pyramid_retry.mark_error_retryable(error)[source]¶
Mark an exception instance or type as retryable. If this exception is caught by
pyramid_retry
then it may retry the request.
- pyramid_retry.is_error_retryable(request, exc)[source]¶
Return
True
if the exception is recognized as retryable error.This will return
False
if the request is on its last attempt. This will returnFalse
ifpyramid_retry
is inactive for the request.
- pyramid_retry.is_last_attempt(request)[source]¶
Return
True
if the request is on its last attempt, meaning thatpyramid_retry
will not be issuing any new attempts, regardless of what happens when executing this request.This will return
True
ifpyramid_retry
is inactive for the request.
- class pyramid_retry.LastAttemptPredicate(val, config)[source]¶
A view predicate registered as
last_retry_attempt
. Can be used to determine if an exception view should execute based on whether it’s the last retry attempt before aborting the request.See also
- class pyramid_retry.RetryableErrorPredicate(val, config)[source]¶
A view predicate registered as
retryable_error
. Can be used to determine if an exception view should execute based on whether the exception is a retryable error.See also
- exception pyramid_retry.RetryableException[source]¶
A retryable exception should be raised when an error occurs.
- interface pyramid_retry.IRetryableError[source]¶
A marker interface for retryable errors.
An interface can be applied to any
Exception
class or object to indicate that it should be treated as a retryable error.