From: Michael Tremer Date: Tue, 21 Jan 2025 10:18:16 +0000 (+0000) Subject: mirrors: Add faster timeouts to mirror checks X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a4137ffe7e1dff8c18e3497b2c1f6a3f7095b6a7;p=ipfire.org.git mirrors: Add faster timeouts to mirror checks The checker used to freeze here sometimes as the default timeouts where pretty much to infinity and beyond. Signed-off-by: Michael Tremer --- diff --git a/src/backend/mirrors.py b/src/backend/mirrors.py index b1d8a6a5..26958553 100644 --- a/src/backend/mirrors.py +++ b/src/backend/mirrors.py @@ -238,8 +238,18 @@ class Mirror(Object): async def check_timestamp(self): try: - response = await self.backend.http_client.fetch(self.url + ".timestamp", - headers={ "Pragma" : "no-cache" }) + response = await self.backend.http_client.fetch( + self.url + ".timestamp", + headers = { + "Pragma" : "no-cache", + }, + + # We are really not very patient with this, because if the + # mirror cannot give us the timestamp swiftly, it is probably + # very overloaded and won't respond quickly to any file requests. + connect_timeout = 10, + request_timeout = 10, + ) except tornado.httpclient.HTTPError as e: logging.warning("Error getting timestamp from %s: %s" % (self.hostname, e)) self.set_state("DOWN") @@ -288,8 +298,16 @@ class Mirror(Object): return try: - response = await self.backend.http_client.fetch(self.url + ".filelist", - headers={ "Pragma" : "no-cache" }) + response = await self.backend.http_client.fetch( + self.url + ".filelist", + headers = { + "Pragma" : "no-cache", + }, + + # Don't wait very long for this + connect_timeout = 10, + request_timeout = 10, + ) except tornado.httpclient.HTTPError as e: logging.warning("Error getting filelist from %s: %s" % (self.hostname, e)) self.set_state("DOWN")