From e9cf974ab987951fa70d918a7dac32f8681cd9d5 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Apr 14 2021 06:59:41 +0000 Subject: PR#2819: lib: more portable BadStatusLine checking Merges #2819 https://pagure.io/koji/pull-request/2819 Fixes: #2789 https://pagure.io/koji/issue/2789 is_conn_error fails to match BadStatusLine errors in some cases --- diff --git a/koji/__init__.py b/koji/__init__.py index e58a8f2..00e9dba 100644 --- a/koji/__init__.py +++ b/koji/__init__.py @@ -2274,17 +2274,13 @@ def is_conn_error(e): # these values, this is a connection error. if getattr(e, 'errno', None) in (errno.ECONNRESET, errno.ECONNABORTED, errno.EPIPE): return True - if isinstance(e, six.moves.http_client.BadStatusLine): + if 'BadStatusLine' in str(e): + # we see errors like this in keep alive timeout races + # ConnectionError(ProtocolError('Connection aborted.', BadStatusLine("''",)),) return True try: if isinstance(e, requests.exceptions.ConnectionError): - # we see errors like this in keep alive timeout races - # ConnectionError(ProtocolError('Connection aborted.', BadStatusLine("''",)),) e2 = getattr(e, 'args', [None])[0] - if isinstance(e2, requests.packages.urllib3.exceptions.ProtocolError): - e3 = getattr(e2, 'args', [None, None])[1] - if isinstance(e3, six.moves.http_client.BadStatusLine): - return True # same check as unwrapped socket error if getattr(e2, 'errno', None) in (errno.ECONNRESET, errno.ECONNABORTED, errno.EPIPE): return True