libcloud.utils.retry module

class libcloud.utils.retry.Retry(retry_exceptions=(<class 'libcloud.common.exceptions.RateLimitReachedError'>, <class 'OSError'>, <class 'socket.gaierror'>, <class 'http.client.NotConnected'>, <class 'http.client.ImproperConnectionState'>, <class 'libcloud.utils.retry.TransientSSLError'>), retry_delay=1, timeout=30, backoff=1)[source]

Bases: MinimalRetry

Wrapper around retrying that helps to handle common transient exceptions.

This version retries the errors that libcloud.utils.retry:MinimalRetry retries and all errors of the exception types that are given.

Parameters:
  • retry_exceptions – types of exceptions to retry on.

  • retry_delay – retry delay between the attempts.

  • timeout – maximum time to wait.

  • backoff – multiplier added to delay between attempts.

Example:

retry_request = Retry(retry_exceptions=(httplib.NotConnected,),

timeout=1, retry_delay=1, backoff=1)

retry_request(self.connection.request)()

should_retry(exception)[source]
class libcloud.utils.retry.RetryForeverOnRateLimitError(retry_exceptions=(<class 'libcloud.common.exceptions.RateLimitReachedError'>, <class 'OSError'>, <class 'socket.gaierror'>, <class 'http.client.NotConnected'>, <class 'http.client.ImproperConnectionState'>, <class 'libcloud.utils.retry.TransientSSLError'>), retry_delay=1, timeout=30, backoff=1)[source]

Bases: Retry

This class is only here for backward compatibility reasons with pre-Libcloud v3.3.2.

If works by ignoring timeout argument and retrying forever until API is returning 429 RateLimitReached errors.

In most cases using this class is not a good idea since it can cause code to hang and retry for ever in case API continues to return retry limit reached.

Wrapper around retrying that helps to handle common transient exceptions.

This version retries the errors that libcloud.utils.retry:MinimalRetry retries and all errors of the exception types that are given.

Parameters:
  • retry_exceptions – types of exceptions to retry on.

  • retry_delay – retry delay between the attempts.

  • timeout – maximum time to wait.

  • backoff – multiplier added to delay between attempts.

Example:

retry_request = Retry(retry_exceptions=(httplib.NotConnected,),

timeout=1, retry_delay=1, backoff=1)

retry_request(self.connection.request)()