From e2ef37a9dc472704bdfa8c91387addb9c73536f2 Mon Sep 17 00:00:00 2001 From: Emiliano Ciavatta Date: Wed, 14 Dec 2022 17:28:33 +0100 Subject: [PATCH] Add timeout to fetch feed request --- Watcher/Watcher/threats_watcher/core.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Watcher/Watcher/threats_watcher/core.py b/Watcher/Watcher/threats_watcher/core.py index 22e0ea0..4a41cff 100644 --- a/Watcher/Watcher/threats_watcher/core.py +++ b/Watcher/Watcher/threats_watcher/core.py @@ -104,7 +104,7 @@ def fetch_last_posts(nb_max_post): posts_published = dict() for url in rss_urls: try: - feed_content = requests.get(url) + feed_content = requests.get(url, timeout=60) feeds.append(feedparser.parse(feed_content.text)) except requests.exceptions.RequestException as e: print(str(timezone.now()) + " - ", e) @@ -181,7 +181,7 @@ def remove_banned_words(): word = word.replace("'", "") # Remove '/' (sometimes regular expression don't catch this character) word = word.replace("/", "") - + if word: posts_without_banned[word] = count