From 56e5c7ae1da2b94c2699708fa7f80677cfe33668 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Wed, 15 Aug 2012 17:56:15 +0530 Subject: [PATCH] Added a timeout to lyrics fetching --- headphones/lyrics.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/headphones/lyrics.py b/headphones/lyrics.py index c8eda8a6..6899359a 100644 --- a/headphones/lyrics.py +++ b/headphones/lyrics.py @@ -14,7 +14,7 @@ # along with Headphones. If not, see . import re -import urllib +import urllib, urllib2 from xml.dom import minidom import htmlentitydefs @@ -30,7 +30,7 @@ def getLyrics(artist, song): searchURL = 'http://lyrics.wikia.com/api.php?' + urllib.urlencode(params) try: - data = urllib.urlopen(searchURL).read() + data = urllib2.urlopen(searchURL, timeout=20).read() except Exception, e: logger.warn('Error opening: %s. Error: %s' % (searchURL, e)) return