1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-12-22 17:06:17 +00:00

Add a timeout when fetching remote resources

This commit is contained in:
Taizo Simpson 2018-10-31 13:20:38 -04:00
parent 370b5bae77
commit 306fc202bd
No known key found for this signature in database
GPG Key ID: D197B1197B2D4D68
2 changed files with 3 additions and 3 deletions

View File

@ -201,7 +201,7 @@ def lyrics():
try: try:
r = requests.get("http://api.chartlyrics.com/apiv1.asmx/SearchLyricDirect", r = requests.get("http://api.chartlyrics.com/apiv1.asmx/SearchLyricDirect",
params = { 'artist': artist, 'song': title }) params = { 'artist': artist, 'song': title }, timeout = 5)
root = ElementTree.fromstring(r.content) root = ElementTree.fromstring(r.content)
ns = { 'cl': 'http://api.chartlyrics.com/' } ns = { 'cl': 'http://api.chartlyrics.com/' }

View File

@ -77,9 +77,9 @@ class LastFm:
try: try:
if write: if write:
r = requests.post('http://ws.audioscrobbler.com/2.0/', data = kwargs) r = requests.post('http://ws.audioscrobbler.com/2.0/', data = kwargs, timeout = 5)
else: else:
r = requests.get('http://ws.audioscrobbler.com/2.0/', params = kwargs) r = requests.get('http://ws.audioscrobbler.com/2.0/', params = kwargs, timeout = 5)
except requests.exceptions.RequestException as e: except requests.exceptions.RequestException as e:
self.__logger.warning('Error while connecting to LastFM: ' + str(e)) self.__logger.warning('Error while connecting to LastFM: ' + str(e))
return None return None