Improved retry logic

This commit is contained in:
Paul Lamere 2015-06-08 14:37:19 +02:00
parent fd9441a1e7
commit 10cf88da90

View File

@ -135,6 +135,17 @@ class Spotify(object):
else: else:
print ('http status:' + str(status)) print ('http status:' + str(status))
raise 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): def _post(self, url, args=None, payload=None, **kwargs):
if args: if args: