Notice: Over the next few months, we're reorganizing the App Engine documentation site to make it easier to find content and better align with the rest of Google Cloud products. The same content will be available, but the navigation will now match the rest of the Cloud products. If you have feedback or questions as you navigate the site, click Send Feedback.

Python 2 is no longer supported by the community. We recommend that you migrate Python 2 apps to Python 3.

The RetryParams Class

Stay organized with collections Save and categorize content based on your preferences.

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


The App Engine client library for Cloud Storage 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 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 effect 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. Default is 0.1. Delay helps distribute load at the Google Cloud Storage server.
The exponential back-off multiplier, used to determine optimal processing rate. Default is 2.0. 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. Default is 10.0.
The minimum number of times to retry. Default is 3.
The maximum number of times to retry. Set this value to 0 if you don't want any retries. Default is 6.
The maximum number of seconds that can be spent on all retries of a given request. Default is 30.0. 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.