mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-30 06:49:24 +01:00
RSS: Do no block commands calling while loading a feed.
This commit is contained in:
parent
e676cc284b
commit
1650860032
@ -63,6 +63,18 @@ addConverter('feedName', get_feedName)
|
|||||||
announced_headlines_filename = \
|
announced_headlines_filename = \
|
||||||
conf.supybot.directories.data.dirize('RSS_announced.flat')
|
conf.supybot.directories.data.dirize('RSS_announced.flat')
|
||||||
|
|
||||||
|
def only_one_at_once(f):
|
||||||
|
lock = [False]
|
||||||
|
def newf(*args, **kwargs):
|
||||||
|
if lock[0]:
|
||||||
|
return
|
||||||
|
lock[0] = True
|
||||||
|
try:
|
||||||
|
f(*args, **kwargs)
|
||||||
|
finally:
|
||||||
|
lock[0] = False
|
||||||
|
return newf
|
||||||
|
|
||||||
class Feed:
|
class Feed:
|
||||||
__slots__ = ('url', 'name', 'data', 'last_update', 'entries',
|
__slots__ = ('url', 'name', 'data', 'last_update', 'entries',
|
||||||
'etag', 'modified', 'initial',
|
'etag', 'modified', 'initial',
|
||||||
@ -129,7 +141,6 @@ def save_announces_db(db, fd):
|
|||||||
json.dump(dict((name, list(entries)) for (name, entries) in db), fd)
|
json.dump(dict((name, list(entries)) for (name, entries) in db), fd)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class RSS(callbacks.Plugin):
|
class RSS(callbacks.Plugin):
|
||||||
"""This plugin is useful both for announcing updates to RSS feeds in a
|
"""This plugin is useful both for announcing updates to RSS feeds in a
|
||||||
channel, and for retrieving the headlines of RSS feeds via command. Use
|
channel, and for retrieving the headlines of RSS feeds via command. Use
|
||||||
@ -230,7 +241,7 @@ class RSS(callbacks.Plugin):
|
|||||||
|
|
||||||
def __call__(self, irc, msg):
|
def __call__(self, irc, msg):
|
||||||
self.__parent.__call__(irc, msg)
|
self.__parent.__call__(irc, msg)
|
||||||
self.update_feeds()
|
threading.Thread(target=self.update_feeds).start()
|
||||||
|
|
||||||
|
|
||||||
##################
|
##################
|
||||||
@ -274,6 +285,7 @@ class RSS(callbacks.Plugin):
|
|||||||
if self.is_expired(feed):
|
if self.is_expired(feed):
|
||||||
self.update_feed(feed)
|
self.update_feed(feed)
|
||||||
|
|
||||||
|
@only_one_at_once
|
||||||
def update_feeds(self):
|
def update_feeds(self):
|
||||||
announced_feeds = set()
|
announced_feeds = set()
|
||||||
for irc in world.ircs:
|
for irc in world.ircs:
|
||||||
|
@ -242,12 +242,15 @@ class SupyHTTPRequestHandler(BaseHTTPRequestHandler):
|
|||||||
def do_POST(self):
|
def do_POST(self):
|
||||||
if 'Content-Type' not in self.headers:
|
if 'Content-Type' not in self.headers:
|
||||||
self.headers['Content-Type'] = 'application/x-www-form-urlencoded'
|
self.headers['Content-Type'] = 'application/x-www-form-urlencoded'
|
||||||
form = cgi.FieldStorage(
|
if self.headers['Content-Type'] == 'application/x-www-form-urlencoded':
|
||||||
fp=self.rfile,
|
form = cgi.FieldStorage(
|
||||||
headers=self.headers,
|
fp=self.rfile,
|
||||||
environ={'REQUEST_METHOD':'POST',
|
headers=self.headers,
|
||||||
'CONTENT_TYPE':self.headers['Content-Type'],
|
environ={'REQUEST_METHOD':'POST',
|
||||||
})
|
'CONTENT_TYPE':self.headers['Content-Type'],
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
form = self.rfile.read()
|
||||||
self.do_X('doPost', form=form)
|
self.do_X('doPost', form=form)
|
||||||
|
|
||||||
def do_HEAD(self):
|
def do_HEAD(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user