use locking on rss entries

workspace
Brendan Howell 5 years ago
parent d56d75e48e
commit 515ad8e325

@ -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))

Loading…
Cancel
Save