diff options
author | EdLeafe <ed@leafe.com> | 2013-06-12 17:43:01 -0500 |
---|---|---|
committer | EdLeafe <ed@leafe.com> | 2013-06-13 11:14:28 -0500 |
commit | 7b9f304485b990e0b4e3d4373e28b0ac54ea8a0e (patch) | |
tree | 6021c5770ee1c03797b49ce593eb70a3d03ced36 | |
parent | 473167ff31a529db02ff6f3483e30263b56e20a6 (diff) | |
download | python-swiftclient-7b9f304485b990e0b4e3d4373e28b0ac54ea8a0e.tar.gz |
Fixes re-auth flow with expired tokens.
The re-authentication of expired tokens assumed that the 401 would
always occur on the first HTTP at tempt. This fix changes that so that
re-auth is still only attempted once, but no longer has to be on the
first attempt.
Change-Id: I93a1187da3637287a803a59c146256d4f543c9d5
Fixes: bug #1131142
-rw-r--r-- | swiftclient/client.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/swiftclient/client.py b/swiftclient/client.py index 04a539c..3d848cd 100644 --- a/swiftclient/client.py +++ b/swiftclient/client.py @@ -1034,6 +1034,7 @@ class Connection(object): def _retry(self, reset_func, func, *args, **kwargs): self.attempts = 0 + retried_auth = False backoff = self.starting_backoff while self.attempts <= self.retries: self.attempts += 1 @@ -1055,10 +1056,11 @@ class Connection(object): raise if err.http_status == 401: self.url = self.token = None - if self.attempts > 1 or not all((self.authurl, - self.user, - self.key)): + if retried_auth or not all((self.authurl, + self.user, + self.key)): raise + retried_auth = True elif err.http_status == 408: self.http_conn = None elif 500 <= err.http_status <= 599: |