From 7e9a1d11c20f67d08818538bbe917d319e8e4fcf Mon Sep 17 00:00:00 2001 From: rembo10 Date: Sun, 24 Jun 2012 18:20:04 +0530 Subject: [PATCH] Put some timeouts on the urlopens --- headphones/cache.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/headphones/cache.py b/headphones/cache.py index 8277d343..fa3e1083 100644 --- a/headphones/cache.py +++ b/headphones/cache.py @@ -214,7 +214,7 @@ class Cache(object): logger.debug('Retrieving artist information from: ' + url) try: - result = urllib2.urlopen(url).read() + result = urllib2.urlopen(url, timeout=20).read() except: logger.warn('Could not open url: ' + url) return @@ -261,7 +261,7 @@ class Cache(object): logger.debug('Retrieving artist information from: ' + url) try: - result = urllib2.urlopen(url).read() + result = urllib2.urlopen(url, timeout=20).read() except: logger.warn('Could not open url: ' + url) return @@ -322,7 +322,7 @@ class Cache(object): if image_url and self.query_type == 'artwork': try: - artwork = urllib2.urlopen(image_url).read() + artwork = urllib2.urlopen(image_url, timeout=20).read() except Exception, e: logger.error('Unable to open url "' + image_url + '". Error: ' + str(e)) artwork = None @@ -361,7 +361,7 @@ class Cache(object): if thumb_url and self.query_type in ['thumb','artwork'] and not (self.thumb_files and self._is_current(self.thumb_files[0])): try: - artwork = urllib2.urlopen(thumb_url).read() + artwork = urllib2.urlopen(thumb_url, timeout=20).read() except Exception, e: logger.error('Unable to open url "' + thumb_url + '". Error: ' + str(e)) artwork = None