Skip to main content

Middleware which implements a retryable exceptions

Project description

This package implements a WSGI middleware filter which intercepts “retryable” exceptions and retries the WSGI request a configurable number of times. If the request cannot be satisfied via retries, the exception is reraised.

Installation

Install using setuptools, e.g. (within a virtualenv):

$ easy_install repoze.retry

Configuration via Python

Wire up the middleware in your application:

from repoze.retry import Retry
mw = Retry(app, tries=3, retryable=(ValueError, IndexError))

By default, the retryable exception is repoze.retry.ConflictError (or if ZODB is installed, it’s ZODB.POSException.ConflictError); the tries count defaults to 3 times.

Configuration via Paste

If you want to use the default configuration, you can just include the filter in your application’s pipeline. Note that the filter should come before (to the “left”) of the repoze.tm filter, your pipeline includes it, so that retried requests are first aborted and then restarted in a new transaction:

[pipeline:main]
pipeline = egg:Paste#cgitb
           egg:Paste#httpexceptions
           egg:repoze.retry#retry
           egg:repoze.tm#tm
           egg:repoze.vhm#vhm_xheaders
           zope2

If you want to override the defaults, e.g. to change the number of retries, or the exceptions which will be retried, you need to make a separate section for the filter:

[filter:retry]
use = egg:repoze.retry
tries = 2
retryable = mypackage.exceptions:SomeRetryableException

and then use it in the pipeline:

[pipeline:main]
pipeline = egg:Paste#cgitb
           egg:Paste#httpexceptions
           retry
           myapp

Reporting Bugs / Development Versions

Visit http://bugs.repoze.org to report bugs. Visit http://svn.repoze.org to download development or tagged versions.

0.9.3 (2009-09-30)

  • Don’t write a temporary file unless the request content length is greater than 2MB (use a StringIO instead).

  • Make ZPublisher.Publish:Retry exceptions retryable (via a soft dependency). This makes repoze.retry work the same as the Zope 2 publisher when that module is installed.

  • 100% test coverage.

  • Change documentation to show proper retryable exception syntax in paste config.

0.9.2 (2008-07-30)

  • Close the app_iter at appropriate points to silence lint errors.

  • Return a Bad Request error if we get a socket error while reading input.

  • Fix traceback output to wsgi.errors (it was going to console).

  • Assert that downstream app must call start_response before successfully returning.

0.9.1 (2008-06-18)

  • Seek wsgi.input back to zero before retrying a request due to a conflict error.

0.9 (2008-06-15)

  • Fixed concurrency bug whereby a response from one request might be returned as result of a different request.

  • Initial PyPI release.

0.8

  • Added WSGI conformance testing for the middleware.

0.7

  • Made the retryable exception(s) configurable, removing the hardwired dependency on ZODB3.

0.6

  • Relaxed requirement for ZODB 3.7.2, since we might need to use the package with other verions.

0.5

  • Depend on PyPI release of ZODB 3.7.2. Upgrade to this by doing bin/easy_install -U ‘ZODB3 >= 3.7.2, < 3.8.0a’ if necessary.

0.4

  • Write retry attempts to ‘wsgi.errors’ stream if availabile.

  • Depend on rerolled ZODB 3.7.1 instead of zopelib.

  • Add license and copyright, change trove classifiers.

0.3

  • We now buffer the result of a downstream application’s ‘start_response’ call so we can retry requests which have already called start_response without breaking the WSGI spec (the server’s start_response may only be called once unless there is an exception, and then it needs to be called with an exc_info three-tuple, although we’re uninterested in that case here).

0.2

  • The entry point name was wrong (it referred to “tm”). Change it so that egg:repoze.retry#retry should work in paste configs.

  • Depend on zopelib rather than ZODB 3.8.0b3 distribution, because the ZODB distribution pulls in various packages (zope.interface and ZEO most notably) that are incompatible with stock Zope 2.10.4 apps and older sandboxes. We’ll need to revisit this.

0.1

  • 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

repoze.retry-0.9.3.tar.gz (9.5 kB view details)

Uploaded Source

File details

Details for the file repoze.retry-0.9.3.tar.gz.

File metadata

  • Download URL: repoze.retry-0.9.3.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for repoze.retry-0.9.3.tar.gz
Algorithm Hash digest
SHA256 6d109092b64a842ce81ec2c89daf4c3af397ef47d07b95fc70729a3f58a3b4d2
MD5 ec87d9c72c1cd54eca1c86fcfabe3717
BLAKE2b-256 bd9c1a4f2be9c03f36cfdb5ebf4b0720eed5990cc1e58f270f0cd5003f3a5018

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page