The RetryParams Class

RetryParams is provided by the Google Cloud Storage client library contained in src/cloudstorage. This class lets you change default settings used to handle timeouts and retries.


The Google Cloud Storage client library uses default settings for handling timeouts and retries during attempts to contact Google Cloud Storage servers. This class allows you to change those settings, either on an application-wide basis, or for a specific invocation of a Google Cloud Storage client library function (copy2, delete, listbucket, open, stat). You need change only the specific setting you are interested in, as all other settings are retained unless explicitly overwritten. Each RetryParams instance is unique per thread and per request.

To change a default setting application-wide, you create a RetryParams object, specify whatever settings you wish to change, and supply this object to the cloudstorage.set_default_retry_params() function as follows:

my_default_retry_params = cloudstorage.RetryParams(initial_delay=0.2,

To change default settings for a specific function invocation only, create a RetryParams object and supply it directly to the function in its retry_params parameter, as follows:

write_retry_params = cloudstorage.RetryParams(backoff_factor=1.1)
gcs_file =,
                    options={'x-goog-meta-foo': 'foo',
                             'x-goog-meta-bar': 'bar'},

This has no affect on the default settings used by the app or by other function invocations.

Instance Properties

A RetryParams instance has the following properties:

The number of seconds to delay before a retry. Delay helps distribute load at the Google Cloud Storage server.
The exponential back-off multiplier, used to determine optimal processing rate. For a description and recommendations for setting this value, see the Google Cloud Storage documentation on backoff
The maximum number of seconds to wait between retries.
The minimum number of times to retry.
The maximum number of times to retry. Set this value to 0 if you don't want any retries.
The maximum number of seconds that can be spent on all retries of a given request. Retry stops when this period passed AND min_retries has been attempted.
The number of seconds to wait for UrlFetch to contact the Google Cloud Storage servers before returning a timeout error. By default, this is set to None, which means use the default UrlFetch deadline which is five seconds. You can set this to any value up to a maximum of 60 seconds.

Send feedback about...

App Engine standard environment for Python