Allow user to enable failed HTTP requests retry by setting libcloud.common.base.RETRY_FAILED_HTTP_REQUESTS module level variable.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/c86d45b9 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/c86d45b9 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/c86d45b9 Branch: refs/heads/trunk Commit: c86d45b930cee84b895cbf706f99ae34b9e161ac Parents: 5f870db Author: Tomaz Muraus <[email protected]> Authored: Sun Jul 19 17:49:22 2015 +0800 Committer: Tomaz Muraus <[email protected]> Committed: Sun Jul 19 17:51:26 2015 +0800 ---------------------------------------------------------------------- libcloud/common/base.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/c86d45b9/libcloud/common/base.py ---------------------------------------------------------------------- diff --git a/libcloud/common/base.py b/libcloud/common/base.py index 4663e69..ad97fc3 100644 --- a/libcloud/common/base.py +++ b/libcloud/common/base.py @@ -52,6 +52,29 @@ from libcloud.common.types import LibcloudError, MalformedResponseError from libcloud.httplib_ssl import LibcloudHTTPConnection from libcloud.httplib_ssl import LibcloudHTTPSConnection +__all__ = [ + 'RETRY_FAILED_HTTP_REQUESTS', + + 'BaseDriver', + + 'Connection', + 'PollingConnection', + 'ConnectionKey', + 'ConnectionUserAndKey', + 'CertificateConnection', + 'LoggingHTTPConnection', + 'LoggingHTTPSConnection' + + 'Response', + 'HTTPResponse', + 'JsonResponse', + 'XmlResponse', + 'RawResponse' +] + +# Module level variable indicates if the failed HTTP requests should be retried +RETRY_FAILED_HTTP_REQUESTS = False + class HTTPResponse(httplib.HTTPResponse): # On python 2.6 some calls can hang because HEAD isn't quite properly @@ -683,7 +706,7 @@ class Connection(object): headers = copy.copy(headers) retry_enabled = os.environ.get('LIBCLOUD_RETRY_FAILED_HTTP_REQUESTS', - False) + False) or RETRY_FAILED_HTTP_REQUESTS action = self.morph_action_hook(action) self.action = action
