mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-11 12:42:34 +01:00
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()
|
||||
|
||||
def getFeed(self, url):
|
||||
def error(s):
|
||||
return {'items': [{'title': s}]}
|
||||
try:
|
||||
# This is the most obvious place to acquire the lock, because a
|
||||
# malicious user could conceivably flood the bot with rss commands
|
||||
@ -218,13 +220,15 @@ class RSS(callbacks.Privmsg):
|
||||
except sgmllib.SGMLParseError:
|
||||
self.log.exception('Uncaught exception from rssparser:')
|
||||
raise callbacks.Error, 'Invalid (unparseable) RSS feed.'
|
||||
except socket.timeout:
|
||||
return error('Timeout downloading feed.')
|
||||
self.cachedFeeds[url] = results
|
||||
self.lastRequest[url] = time.time()
|
||||
try:
|
||||
return self.cachedFeeds[url]
|
||||
except KeyError:
|
||||
self.lastRequest[url] = 0
|
||||
return {'items': [{'title': 'Unable to download feed.'}]}
|
||||
return error('Unable to download feed.')
|
||||
finally:
|
||||
self.releaseLock(url)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user