mirror of
https://github.com/maubot/rss.git
synced 2025-07-26 00:25:36 -04:00
Fix handling errors in feed parsing
This commit is contained in:
parent
ad39e34ae2
commit
2079504e39
1 changed files with 8 additions and 1 deletions
|
@ -109,7 +109,7 @@ class RSSBot(Plugin):
|
||||||
subs = self.db.get_feeds()
|
subs = self.db.get_feeds()
|
||||||
if not subs:
|
if not subs:
|
||||||
return
|
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
|
feed, entries = await res
|
||||||
if not entries:
|
if not entries:
|
||||||
continue
|
continue
|
||||||
|
@ -135,6 +135,13 @@ class RSSBot(Plugin):
|
||||||
self.log.exception("Error while polling feeds")
|
self.log.exception("Error while polling feeds")
|
||||||
await asyncio.sleep(self.config["update_interval"] * 60, loop=self.loop)
|
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
|
async def parse_feed(self, *, feed: Optional[Feed] = None, url: Optional[str] = None
|
||||||
) -> Tuple[Feed, Iterable[Entry]]:
|
) -> Tuple[Feed, Iterable[Entry]]:
|
||||||
if feed is None:
|
if feed is None:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue