pymemcache.client.retrying module

Module containing the RetryingClient wrapper class.

class pymemcache.client.retrying.RetryingClient(client, attempts=2, retry_delay=0, retry_for=None, do_not_retry_for=None)

Bases: object

Client that allows retrying calls for the other clients.

__init__(client, attempts=2, retry_delay=0, retry_for=None, do_not_retry_for=None)

Constructor for RetryingClient.

Parameters
  • client – Client|PooledClient|HashClient, inner client to use for performing actual work.

  • attempts – optional int, how many times to attempt an action before failing. Must be 1 or above. Defaults to 2.

  • retry_delay – optional int|float, how many seconds to sleep between each attempt. Defaults to 0.

  • retry_for

    optional None|tuple|set|list, what exceptions to allow retries for. Will allow retries for all exceptions if None. .. rubric:: Example

    (MemcacheClientError, MemcacheUnexpectedCloseError)

    Accepts any class that is a subclass of Exception. Defaults to None.

  • do_not_retry_for

    optional None|tuple|set|list, what exceptions should be retried. Will not block retries for any Exception if None. .. rubric:: Example

    (IOError, MemcacheIllegalInputError)

    Accepts any class that is a subclass of Exception. Defaults to None.

Exceptions:

ValueError: If attempts is not 1 or above. ValueError: If retry_for or do_not_retry_for is not None, tuple or

Iterable.

ValueError: If any of the elements of retry_for or

do_not_retry_for is not a subclass of Exception.

ValueError: If there is any overlap between retry_for and

do_not_retry_for.