pyramid_retry API¶
- pyramid_retry.includeme(config)[source]¶
Activate the
pyramid_retryexecution policy in your application.This will add the
pyramid_retry.RetryableErrorPolicy()withattemptspulled from theretry.attemptssetting.The
last_retry_attemptandretryable_errorview 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
attemptsattempts.If
activate_hookis 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 orNonewhich 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_retrythen it may retry the request.
- pyramid_retry.is_error_retryable(request, exc)[source]¶
Return
Trueif the exception is recognized as retryable error.This will return
Falseif the request is on its last attempt. This will returnFalseifpyramid_retryis inactive for the request.
- pyramid_retry.is_last_attempt(request)[source]¶
Return
Trueif the request is on its last attempt, meaning thatpyramid_retrywill not be issuing any new attempts, regardless of what happens when executing this request.This will return
Trueifpyramid_retryis 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
Exceptionclass or object to indicate that it should be treated as a retryable error.
- interface pyramid_retry.IBeforeRetry[source]¶
An event emitted immediately prior to throwing away the request and creating a new one.
This event may be useful when state is stored on the
request.environthat needs to be updated before a new request is created.- environ¶
The environ object that is reused between requests.
- exception¶
The exception that request processing raised.
- request¶
The request object that is being discarded.
- response¶
The response object that is being discarded. This may be
Noneif no response was generated, which happens when request processing raises an exception that isn't caught by any exception view.