summaryrefslogtreecommitdiff
path: root/swiftclient
diff options
context:
space:
mode:
authorMike Widman <mwidman@endurancewindpower.com>2013-07-10 10:52:02 -0700
committerMike Widman <mwidman@endurancewindpower.com>2013-07-12 14:53:30 -0700
commit6411fd38462a9e6ea9f5e0b44d9afe6fa54c0791 (patch)
treedf0fb5406ee63e0a0cff8196a84611de6601ec2f /swiftclient
parentc460ebff0a6ab284d47e215f7f9156e73e7a40a9 (diff)
downloadpython-swiftclient-6411fd38462a9e6ea9f5e0b44d9afe6fa54c0791.tar.gz
Adds max-backoff for retries in Connection.
The max-backoff concept prevents the backoff used in _retry to double infinitely (which in turn causes wait times of an hour or more between retries). As per review, changed code to use min instead. Fixes: bug #1183542 Change-Id: Ic084f54069b7fa7a33604741487045c5e697ff06
Diffstat (limited to 'swiftclient')
-rw-r--r--swiftclient/client.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/swiftclient/client.py b/swiftclient/client.py
index 03dad31..0a32033 100644
--- a/swiftclient/client.py
+++ b/swiftclient/client.py
@@ -1044,9 +1044,9 @@ class Connection(object):
def __init__(self, authurl=None, user=None, key=None, retries=5,
preauthurl=None, preauthtoken=None, snet=False,
- starting_backoff=1, tenant_name=None, os_options=None,
- auth_version="1", cacert=None, insecure=False,
- ssl_compression=True):
+ starting_backoff=1, max_backoff=64, tenant_name=None,
+ os_options=None, auth_version="1", cacert=None,
+ insecure=False, ssl_compression=True):
"""
:param authurl: authentication URL
:param user: user name to authenticate as
@@ -1081,6 +1081,7 @@ class Connection(object):
self.attempts = 0
self.snet = snet
self.starting_backoff = starting_backoff
+ self.max_backoff = max_backoff
self.auth_version = auth_version
self.os_options = os_options or {}
if tenant_name:
@@ -1152,7 +1153,7 @@ class Connection(object):
else:
raise
sleep(backoff)
- backoff *= 2
+ backoff = min(backoff * 2, self.max_backoff)
if reset_func:
reset_func(func, *args, **kwargs)