Fix handling errors in feed parsing

This commit is contained in:
Tulir Asokan 2020-08-03 03:19:32 +03:00
parent ad39e34ae2
commit 2079504e39

View File

@ -109,7 +109,7 @@ class RSSBot(Plugin):
subs = self.db.get_feeds()
if not subs:
return
for res in asyncio.as_completed([self.parse_feed(feed=feed) for feed in subs]):
for res in asyncio.as_completed([self.try_parse_feed(feed=feed) for feed in subs]):
feed, entries = await res
if not entries:
continue
@ -135,6 +135,13 @@ class RSSBot(Plugin):
self.log.exception("Error while polling feeds")
await asyncio.sleep(self.config["update_interval"] * 60, loop=self.loop)
async def try_parse_feed(self, feed: Optional[Feed] = None) -> Tuple[Feed, Iterable[Entry]]:
try:
return await self.parse_feed(feed=feed)
except Exception:
self.log.exception(f"Failed to parse feed {feed.id} / {feed.url}")
return feed, []
async def parse_feed(self, *, feed: Optional[Feed] = None, url: Optional[str] = None
) -> Tuple[Feed, Iterable[Entry]]:
if feed is None: