An execution policy for Pyramid that supports retrying requests after certain failure exceptions.
Project description
pyramid_retry is an execution policy for Pyramid that wraps requests and can retry them a configurable number of times under certain “retryable” error conditions before indicating a failure to the client.
Usage
Activate pyramid_retry by including it in your application:
def main(global_config, **settings):
config = Configurator(settings=settings)
config.include('pyramid_retry')
# ...
config.add_route('home', '/')
By default pyramid_retry will register an instance of pyramid_retry.RetryableExecutionPolicy as an execution policy in your application using the retry.attempts setting as the maximum number of attempts per request. The default number of attempts is 1.
The policy will handle any requests that fail because the application raised an instance of pyramid_retry.RetryableException or another exception implementing the pyramid_retry.IRetryableError interface:
@view_config(route_name='home')
def failing_view(request):
raise RetryableException
@view_config(route_name='home', last_retry_attempt=True, renderer='string')
def recovery_view(request):
return 'success'
In this example, assuming retry.attempts was set to 3, the failing_view would be executed twice and finally the recover_view would return success on the final attempt.
unreleased
Initial release.
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
Built Distribution
Hashes for pyramid_retry-0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e98d69ef4ddedf1b12afa24ab88dabcc08d8f77533a6f76247c0c03b5363ea7d |
|
MD5 | d3560e4f75c414118018e91b692dd046 |
|
BLAKE2b-256 | 0efe333ddbd3cd56293f8d0a7bf1ab7eb38b7a5fb8fb3056039a22f04d0193d4 |