From: Christian Heller Date: Sun, 17 Jan 2016 20:02:37 +0000 (+0100) Subject: Add timeout to urlopen(). X-Git-Url: https://plomlompom.com/repos/%22https:/validator.w3.org/day?a=commitdiff_plain;h=9a7e2920a88ea32412427c1395b47cdf6d2775cb;p=plomlombot-irc.git Add timeout to urlopen(). --- 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',