Skip to main content

An execution policy for Pyramid that supports retrying requests after certain failure exceptions.

Project description

https://img.shields.io/pypi/v/pyramid_retry.svg https://img.shields.io/travis/Pylons/pyramid_retry.svg Documentation Status

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

pyramid_retry-0.1.tar.gz (16.0 kB view hashes)

Uploaded Source

Built Distribution

pyramid_retry-0.1-py2.py3-none-any.whl (6.8 kB view hashes)

Uploaded Python 2 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