mirror of
https://github.com/c0de-archive/spotipy.git
synced 2025-01-08 15:42:48 +00:00
Added automatic retry logic for gets
This commit is contained in:
parent
c8c44c1b28
commit
a78421a6e8
@ -6,8 +6,9 @@ v1.45, July 7, 2014 -- Support for related artists endpoint. Don't used
|
|||||||
cache auth codes when scope changes
|
cache auth codes when scope changes
|
||||||
v1.50, August 14, 2014 -- Refactored util out of examples and into the main
|
v1.50, August 14, 2014 -- Refactored util out of examples and into the main
|
||||||
package
|
package
|
||||||
v1.301, August 19, 2014 -- Upgraded version number to take precedence over
|
v2.301, August 19, 2014 -- Upgraded version number to take precedence over
|
||||||
previously botched release (sigh)
|
previously botched release (sigh)
|
||||||
v1.310, August 20, 2014 -- Added playlist replace and remove methods. Added auth
|
v2.310, August 20, 2014 -- Added playlist replace and remove methods. Added auth
|
||||||
tests. Improved API docs
|
tests. Improved API docs
|
||||||
v1.310, January 05, 2015 -- Added session support
|
v2.310, January 05, 2015 -- Added session support
|
||||||
|
v2.3.1, March 28, 2015 -- auto retry support
|
||||||
|
@ -65,3 +65,4 @@ If you have suggestions, bugs or other issues specific to this library, file the
|
|||||||
- v2.1.0 - October 25, 2014 -- Added support for new_releases and featured_playlists
|
- v2.1.0 - October 25, 2014 -- Added support for new_releases and featured_playlists
|
||||||
- v2.2.0 - November 15, 2014 -- Added support for user_playlist_tracks
|
- v2.2.0 - November 15, 2014 -- Added support for user_playlist_tracks
|
||||||
- v2.3.0 - January 5, 2015 -- Added session support added by akx.
|
- v2.3.0 - January 5, 2015 -- Added session support added by akx.
|
||||||
|
- v2.3.2 - March 31, 2015 -- Added auto retry logic
|
||||||
|
2
setup.py
2
setup.py
@ -2,7 +2,7 @@ from setuptools import setup
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='spotipy',
|
name='spotipy',
|
||||||
version='2.3.0',
|
version='2.3.2',
|
||||||
description='simple client for the Spotify Web API',
|
description='simple client for the Spotify Web API',
|
||||||
author="@plamere",
|
author="@plamere",
|
||||||
author_email="paul@echonest.com",
|
author_email="paul@echonest.com",
|
||||||
|
@ -6,6 +6,7 @@ import sys
|
|||||||
import base64
|
import base64
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
|
import time
|
||||||
|
|
||||||
''' A simple and thin Python library for the Spotify Web API
|
''' A simple and thin Python library for the Spotify Web API
|
||||||
'''
|
'''
|
||||||
@ -39,6 +40,7 @@ class Spotify(object):
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
trace = False # Enable tracing?
|
trace = False # Enable tracing?
|
||||||
|
max_get_retries = 5
|
||||||
|
|
||||||
def __init__(self, auth=None, requests_session=True,
|
def __init__(self, auth=None, requests_session=True,
|
||||||
client_credentials_manager=None):
|
client_credentials_manager=None):
|
||||||
@ -112,7 +114,19 @@ class Spotify(object):
|
|||||||
def _get(self, url, args=None, payload=None, **kwargs):
|
def _get(self, url, args=None, payload=None, **kwargs):
|
||||||
if args:
|
if args:
|
||||||
kwargs.update(args)
|
kwargs.update(args)
|
||||||
return self._internal_call('GET', url, payload, kwargs)
|
retries = self.max_get_retries
|
||||||
|
while retries > 0:
|
||||||
|
try:
|
||||||
|
return self._internal_call('GET', url, payload, kwargs)
|
||||||
|
except SpotifyException as e:
|
||||||
|
if e.http_status >= 500 and e.http_status < 600:
|
||||||
|
retries -= 1
|
||||||
|
if retries < 0:
|
||||||
|
raise
|
||||||
|
else:
|
||||||
|
time.sleep(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:
|
||||||
|
Loading…
Reference in New Issue
Block a user