From c459ba93b1991ac015b615fae99755f40eb39021 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Tue, 19 Nov 2019 12:11:16 +0100 Subject: [PATCH] Better exceptioon handling on ReadTimout while get-forge-modules --- lib/webhooks/forge/mod_info.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/webhooks/forge/mod_info.py b/lib/webhooks/forge/mod_info.py index ef612e9..56f98c4 100644 --- a/lib/webhooks/forge/mod_info.py +++ b/lib/webhooks/forge/mod_info.py @@ -22,6 +22,7 @@ import pytz # Own modules from fb_tools.common import pp, to_bool +from ..errors import BaseHookError from ..xlate import XLATOR @@ -35,7 +36,7 @@ from .cur_mod_release_info import CurrentModuleReleaseInfo from .owner_info import ForgeOwnerInfo -__version__ = '0.3.1' +__version__ = '0.3.2' LOG = logging.getLogger(__name__) @@ -500,9 +501,15 @@ class ForgeModuleInfo(BaseModuleInfo): m=full_name, u=url)) session = requests.Session() + response = None with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") - response = session.request('GET', url, timeout=http_timeout) + try: + response = session.request('GET', url, timeout=http_timeout) + except requests.exceptions.ReadTimeout as e: + msg = "{c} on getting module info for {m}: {e}".format( + c=e.__class__.__name__, m=full_name, e=e) + raise BaseHookError(msg) if w: warn_class = w[-1].category.__name__ warn_msg = '{}: {}'.format( -- 2.39.5