From: kaliko Date: Fri, 23 Oct 2020 14:14:26 +0000 (+0200) Subject: feeds: catch urllib.error.URLError to avoid killing thread X-Git-Tag: 0.2.0~4 X-Git-Url: https://git.kaliko.me/?p=sid.git;a=commitdiff_plain;h=e89ab76a671bbbe2dc86121f8a0d5738fa21adfc feeds: catch urllib.error.URLError to avoid killing thread --- diff --git a/sid/feeds.py b/sid/feeds.py index 9dc7ea1..7fe5825 100644 --- a/sid/feeds.py +++ b/sid/feeds.py @@ -19,6 +19,8 @@ import threading import time import traceback +from urllib.error import URLError + from feedparser import parse as feed_parse from .plugin import Plugin, botcmd @@ -122,7 +124,9 @@ class FeedMonitor(threading.Thread): for feed in self.feeds_list: try: self.new_posts(feed) - except Exception as err: + except URLError as err: # Non fatal exception + self.plugin.log.error(f'error for {feed}: {err.reason}') + except Exception as err: # Unknown execption, killing thread anyway self.plugin.log.error('feeds thread crashed: %s', err) self.plugin.log.error(''.join(traceback.format_exc())) self.thread_killed = True