Common Utilities¶
Common utilities for Google Media Downloads and Resumable Uploads.
Includes custom exception types, useful constants and shared helpers.
-
exception
google.resumable_media.common.
DataCorruption
(response, *args)[source]¶ Error class for corrupt media transfers.
- Parameters
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
exception
google.resumable_media.common.
InvalidResponse
(response, *args)[source]¶ Error class for responses which are not in the correct state.
- Parameters
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
google.resumable_media.common.
MAX_CUMULATIVE_RETRY
= 600.0¶ Maximum total sleep time allowed during retry process.
This is provided (10 minutes) as a default. When the cumulative sleep exceeds this limit, no more retries will occur.
- Type
-
google.resumable_media.common.
MAX_SLEEP
= 64.0¶ Maximum amount of time allowed between requests.
Used during the retry process for sleep after a failed request. Chosen since it is the power of two nearest to one minute.
- Type
-
google.resumable_media.common.
PERMANENT_REDIRECT
= 308¶ Permanent redirect status code.
It is used by Google services to indicate some (but not all) of a resumable upload has been completed.
http.client.PERMANENT_REDIRECT
was added in Python 3.5, so can’t be used in a “general” code base.For more information, see RFC 7238.
- Type
-
google.resumable_media.common.
RETRYABLE
= (429, <HTTPStatus.INTERNAL_SERVER_ERROR: 500>, <HTTPStatus.BAD_GATEWAY: 502>, <HTTPStatus.SERVICE_UNAVAILABLE: 503>, <HTTPStatus.GATEWAY_TIMEOUT: 504>)¶ HTTP status codes that indicate a retryable error.
Connection errors are also retried, but are not listed as they are exceptions, not status codes.
- Type
iterable
-
class
google.resumable_media.common.
RetryStrategy
(max_sleep=64.0, max_cumulative_retry=None, max_retries=None)[source]¶ Configuration class for retrying failed requests.
At most one of
max_cumulative_retry
andmax_retries
can be specified (they are both caps on the total number of retries). If neither are specified, thenmax_cumulative_retry
is set asMAX_CUMULATIVE_RETRY
.- Parameters
- Raises
ValueError – If both of
max_cumulative_retry
andmax_retries
are passed.