複数のフィードを同時に解析するためにguv
andを使用しています。feedparser
以下は私のコードです:
guv.monkey_patch(time=True, socket=True)
def parse_feed(_feed):
return feedparser.parse(_feed)
def main():
urls = ["http://feeds.bbci.co.uk/news/rss.xml"]
pool = guv.GreenPool()
results = pool.starmap(parse_feed, zip(urls))
for resp in results:
print(str(resp))
ただし、次の出力が得られます。
{'bozo_exception': TypeError('a float is required',), 'bozo': 1, 'feed': {}, 'entries': []}
を使用しても同様の問題Eventlet
がありますが、ネイティブの Python 3threading
ライブラリでは発生しません。