mirror of https://github.com/Mikaela/Limnoria.git
Let's catch some socket.timeout action.
This commit is contained in:
parent
89c3737648
commit
68516b8fec
|
@ -206,6 +206,8 @@ class RSS(callbacks.Privmsg):
|
||||||
self.locks[url].release()
|
self.locks[url].release()
|
||||||
|
|
||||||
def getFeed(self, url):
|
def getFeed(self, url):
|
||||||
|
def error(s):
|
||||||
|
return {'items': [{'title': s}]}
|
||||||
try:
|
try:
|
||||||
# This is the most obvious place to acquire the lock, because a
|
# This is the most obvious place to acquire the lock, because a
|
||||||
# malicious user could conceivably flood the bot with rss commands
|
# malicious user could conceivably flood the bot with rss commands
|
||||||
|
@ -218,13 +220,15 @@ class RSS(callbacks.Privmsg):
|
||||||
except sgmllib.SGMLParseError:
|
except sgmllib.SGMLParseError:
|
||||||
self.log.exception('Uncaught exception from rssparser:')
|
self.log.exception('Uncaught exception from rssparser:')
|
||||||
raise callbacks.Error, 'Invalid (unparseable) RSS feed.'
|
raise callbacks.Error, 'Invalid (unparseable) RSS feed.'
|
||||||
|
except socket.timeout:
|
||||||
|
return error('Timeout downloading feed.')
|
||||||
self.cachedFeeds[url] = results
|
self.cachedFeeds[url] = results
|
||||||
self.lastRequest[url] = time.time()
|
self.lastRequest[url] = time.time()
|
||||||
try:
|
try:
|
||||||
return self.cachedFeeds[url]
|
return self.cachedFeeds[url]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
self.lastRequest[url] = 0
|
self.lastRequest[url] = 0
|
||||||
return {'items': [{'title': 'Unable to download feed.'}]}
|
return error('Unable to download feed.')
|
||||||
finally:
|
finally:
|
||||||
self.releaseLock(url)
|
self.releaseLock(url)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue