From 515ad8e325313dce909e75ced3674c09f7dec0da Mon Sep 17 00:00:00 2001 From: Brendan Howell Date: Thu, 23 Apr 2020 10:59:33 +0200 Subject: [PATCH] use locking on rss entries --- screenless/bureau/publications/publications.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/screenless/bureau/publications/publications.py b/screenless/bureau/publications/publications.py index 890a74e..917cbac 100644 --- a/screenless/bureau/publications/publications.py +++ b/screenless/bureau/publications/publications.py @@ -239,6 +239,7 @@ class Publications(Bureau): for source in feeds: url = source["url"] + feedlock = threading.RLock() def fetch_feed(url, feed_data): """ @@ -246,10 +247,12 @@ class Publications(Bureau): """ try: resp = requests.get(url, timeout=20.0) - feed_data[url] = io.BytesIO(resp.content) + with feedlock: + feed_data[url] = io.BytesIO(resp.content) except requests.ReadTimeout: self.log.warning("Timeout reading RSS feed %s", url) - feed_data[url] = None + with feedlock: + feed_data[url] = None return thread = threading.Thread(target=fetch_feed, args=(url, feed_data))