Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)



The RetryParams Class

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

Introduction

The GCS client library uses default settings for handling timeouts and retries during attempts to contact GCS servers. This class allows you to change those settings, either on an application-wide basis, or for a specific invocation of a GCS client library function ( 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,
                                      max_delay=5.0,
                                      backoff_factor=2,
                                      max_retry_period=15)
cloudstorage.set_default_retry_params(my_default_retry_params)

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 = cloudstorage.open(filename,
                    'w',
                    content_type='text/plain',
                    options={'x-goog-meta-foo': 'foo',
                             'x-goog-meta-bar': 'bar'},
                    retry_params=write_retry_params)

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:

initial_delay
The number of seconds to delay before a retry. Delay helps distribute load at the GCS server.
backoff_factor
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
max_delay
The maximum number of seconds to wait between retries.
min_retries
The minimum number of times to retry.
max_retries
The maximum number of times to retry. Set this value to 0 if you don't want any retries.
max_retry_period
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.
urlfetch_timeout
The number of seconds to wait for UrlFetch to contact the GCS 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.

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.