From 6a6d290cccd869ae033781360680fa37b083d730 Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Wed, 15 May 2024 10:52:41 +0000 Subject: [PATCH] test: furl: Cap time spent waiting for HTTP requests Without an explicit timeout, urllib will wait indefinitely for a connection to be made. --- test/infamy/furl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/infamy/furl.py b/test/infamy/furl.py index 3f7c8a96..bd7b306e 100644 --- a/test/infamy/furl.py +++ b/test/infamy/furl.py @@ -9,10 +9,10 @@ class Furl: """Create new URL checker""" self.url = urllib.parse.quote(url, safe='/:') - def check(self, needle): + def check(self, needle, timeout=10): """Connect to web server URL, fetch body and check for needle""" try: - with urllib.request.urlopen(self.url) as response: + with urllib.request.urlopen(self.url, timeout=timeout) as response: text = response.read().decode('utf-8') #print(text) return needle in text