Solution
try:
randomly_chosen_news_sources = random.choices(tuple(set((source.world_news))), k=2)
first_one_to_try = randomly_chosen_news_sources[0]
backup = randomly_chosen_news_sources[1]
worldnews = feedparser.parse(randomly_chosen_news_source)
except Exception as e:
print(e) # do this first to figure out what the error message is that comes up then replace e with appropriate error
# then log the results
app.logger.error("Connection error while parsing feed {}".format(randomly_chosen_news_source))
worldnews = feedparser.parse(backup)
from tenacity import retry, stop_after_attempt
@retry(stop=stop_after_attempt(5))
def get(self):