From b1a7a49db0a47d104b71ef85f573b0b1178241fa Mon Sep 17 00:00:00 2001 From: Mikhail Volynov Date: Tue, 18 Jul 2017 23:05:53 +0300 Subject: [PATCH] Added request timeout support --- rssutils/rssutils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rssutils/rssutils.py b/rssutils/rssutils.py index 65d07a4..41c805a 100644 --- a/rssutils/rssutils.py +++ b/rssutils/rssutils.py @@ -3,6 +3,7 @@ from bs4 import BeautifulSoup _rss_word_pattern = '([^a-z]|^)rss([^a-z]|$)' +__request_get_timeout = 5 # Request timeout in seconds def search_rss_meta(html): @@ -49,7 +50,7 @@ def get_content(url): error = None r = '' try: - r = requests.get(url) + r = requests.get(url, timeout=__request_get_timeout) if r.status_code != 200: error = r.status_code except: