From 9a7e2920a88ea32412427c1395b47cdf6d2775cb Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Sun, 17 Jan 2016 21:02:37 +0100 Subject: [PATCH] Add timeout to urlopen(). --- plomlombot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plomlombot.py b/plomlombot.py index cf6bae9..36228f3 100644 --- a/plomlombot.py +++ b/plomlombot.py @@ -75,7 +75,7 @@ def url_check(msg): matches = re.findall("(https?://[^\s]+)", msg) for i in range(len(matches)): url = matches[i] - webpage = urllib.request.urlopen(url) + webpage = urllib.request.urlopen(url, timeout=15) content_type = webpage.info().get_content_type() charset = webpage.info().get_content_charset() if not charset or not content_type in ('text/html', 'text/xml', -- 2.30.2