Improved retry logic

This commit is contained in:
Paul Lamere 2015-06-08 14:37:19 +02:00
parent fd9441a1e7
commit 10cf88da90
1 changed files with 11 additions and 0 deletions

View File

@ -135,6 +135,17 @@ class Spotify(object):
else:
print ('http status:' + str(status))
raise
except:
# some other exception. Requests have
# been know to throw a BadStatusLine exception
retries -= 1
if retries >= 0:
print ('retrying ...' + str(delay) + 'secs')
time.sleep(delay)
delay += 1
else:
raise
def _post(self, url, args=None, payload=None, **kwargs):
if args: