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
This commit is contained in:
EdLeafe 2013-06-12 17:43:01 -05:00
parent 473167ff31
commit 7b9f304485

@ -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: