From f94dc19857cec3cc9d8443228454b7e264fffa0e Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 10 Oct 2024 08:01:08 +0200 Subject: ✨ display forum entries: activate/deactivate by user profile - profile form: edit news/forum display MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ishtar_common/utils.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'ishtar_common/utils.py') diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index bf64339e4..b62ee1ddf 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -2833,12 +2833,22 @@ def get_news_feed(): news_feed = cache.get(cache_key) if news_feed is None: news_feed = update_news_feed() - cache.set(cache_key, news_feed, timeout=settings.CACHE_TIMEOUT) + # "" could be a temporary unavailability of the forum re-test 5 minutes later + timeout = settings.CACHE_TIMEOUT if news_feed != "" else 60 * 5 + cache.set(cache_key, news_feed, timeout=timeout) return news_feed def update_news_feed(): - feed = feedparser.parse(settings.ISHTAR_FEED_URL) + try: + response = requests.get(settings.ISHTAR_FEED_URL, timeout=5) + except requests.ReadTimeout: + logger.warning(f"Timeout when reading RSS {settings.ISHTAR_FEED_URL}") + return "" + + # Put it to memory stream object universal feedparser + content = io.BytesIO(response.content) + feed = feedparser.parse(content) news_feed = [] if "entries" in feed: for entry in feed["entries"][:5]: -- cgit v1.2.3