From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 728F3158064 for ; Wed, 8 May 2024 16:24:19 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A81862BC037; Wed, 8 May 2024 16:24:18 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 5BFC02BC037 for ; Wed, 8 May 2024 16:24:18 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id E12C23431CC for ; Wed, 8 May 2024 16:24:14 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 78C8A1A3B for ; Wed, 8 May 2024 16:24:13 +0000 (UTC) From: "Arthur Zamarin" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Arthur Zamarin" Message-ID: <1715185401.298deaf274ff1fdf61de021ee8df060c3ca52033.arthurzam@gentoo> Subject: [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: src/pkgcheck/checks/, src/pkgcheck/addons/ X-VCS-Repository: proj/pkgcore/pkgcheck X-VCS-Files: src/pkgcheck/addons/__init__.py src/pkgcheck/addons/net.py src/pkgcheck/checks/__init__.py X-VCS-Directories: src/pkgcheck/addons/ src/pkgcheck/checks/ X-VCS-Committer: arthurzam X-VCS-Committer-Name: Arthur Zamarin X-VCS-Revision: 298deaf274ff1fdf61de021ee8df060c3ca52033 X-VCS-Branch: master Date: Wed, 8 May 2024 16:24:13 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: f4c19b09-65e6-4606-b5a3-4fdc6fef015b X-Archives-Hash: 5fa86b0eb17574752175ca1440796e12 commit: 298deaf274ff1fdf61de021ee8df060c3ca52033 Author: Lucio Sauer posteo net> AuthorDate: Tue Apr 30 21:28:51 2024 +0000 Commit: Arthur Zamarin gentoo org> CommitDate: Wed May 8 16:23:21 2024 +0000 URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=298deaf2 fix crash when performing --timeout 0 call to ftp:// site e.g. pkgcheck scan --net -c HomepageUrlCheck --timeout 0 app-admin/chrootuid at checkout 127160ac611d39cc6bb2ca21fcf99a086fe2b176 Python's ftplib raises a ValueError with timeout=0. Use timeout=None to put the underlying socket in blocking mode. See https://docs.python.org/3/library/socket.html#socket.socket.settimeout for legal timeout values. Signed-off-by: Lucio Sauer posteo.net> Signed-off-by: Arthur Zamarin gentoo.org> src/pkgcheck/addons/__init__.py | 12 +++++++++++- src/pkgcheck/addons/net.py | 7 +------ src/pkgcheck/checks/__init__.py | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/pkgcheck/addons/__init__.py b/src/pkgcheck/addons/__init__.py index 56678669..c621c53b 100644 --- a/src/pkgcheck/addons/__init__.py +++ b/src/pkgcheck/addons/__init__.py @@ -274,6 +274,16 @@ class UseAddon(base.Addon): class NetAddon(base.Addon): """Addon supporting network functionality.""" + def __init__(self, *args): + super().__init__(*args) + + if self.options.timeout == 0: + # set timeout to 0 to never timeout + self.timeout = None + else: + # default to timing out connections after 5 seconds + self.timeout = self.options.timeout if self.options.timeout is not None else 5 + @classmethod def mangle_argparser(cls, parser): group = parser.add_argument_group("network") @@ -291,7 +301,7 @@ class NetAddon(base.Addon): return Session( concurrent=self.options.tasks, - timeout=self.options.timeout, + timeout=self.timeout, user_agent=self.options.user_agent, ) except ImportError as e: diff --git a/src/pkgcheck/addons/net.py b/src/pkgcheck/addons/net.py index 782d74d1..91101282 100644 --- a/src/pkgcheck/addons/net.py +++ b/src/pkgcheck/addons/net.py @@ -18,12 +18,7 @@ class Session(requests.Session): def __init__(self, concurrent=None, timeout=None, user_agent=None): super().__init__() - if timeout == 0: - # set timeout to 0 to never timeout - self.timeout = None - else: - # default to timing out connections after 5 seconds - self.timeout = timeout if timeout is not None else 5 + self.timeout = timeout # block when urllib3 connection pool is full concurrent = concurrent if concurrent is not None else os.cpu_count() * 5 diff --git a/src/pkgcheck/checks/__init__.py b/src/pkgcheck/checks/__init__.py index b5caa244..556f720e 100644 --- a/src/pkgcheck/checks/__init__.py +++ b/src/pkgcheck/checks/__init__.py @@ -127,7 +127,7 @@ class NetworkCheck(AsyncCheck, OptionalCheck): super().__init__(*args, **kwargs) if not self.options.net: raise SkipCheck(self, "network checks not enabled") - self.timeout = self.options.timeout + self.timeout = net_addon.timeout self.session = net_addon.session