#2824 lib: is_conn_error catch more exceptions
Merged a year ago by tkopecek. Opened a year ago by tkopecek.
tkopecek/koji issue2789a  into  master

file modified
+5 -1
@@ -2274,7 +2274,11 @@ 

      # these values, this is a connection error.

      if getattr(e, 'errno', None) in (errno.ECONNRESET, errno.ECONNABORTED, errno.EPIPE):

          return True

-     if 'BadStatusLine' in str(e):

+     str_e = str(e)

+     if 'BadStatusLine' in str_e or \

+        'RemoteDisconnected' in str_e or \

+        'ConnectionReset' in str_e or \

+        'IncompleteRead' in str_e:

          # we see errors like this in keep alive timeout races

          # ConnectionError(ProtocolError('Connection aborted.', BadStatusLine("''",)),)

          return True

Related: https://pagure.io/koji/issue/2789

Additional nested exceptions can be caught by this (again keepalive problems).

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/urllib3/connectionpool.py", line 665, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3.9/site-packages/urllib3/connectionpool.py", line 421, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/lib/python3.9/site-packages/urllib3/connectionpool.py", line 416, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib64/python3.9/http/client.py", line 1347, in getresponse
    response.begin()
  File "/usr/lib64/python3.9/http/client.py", line 307, in begin
    version, status, reason = self._read_status()
  File "/usr/lib64/python3.9/http/client.py", line 276, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/usr/lib/python3.9/site-packages/urllib3/connectionpool.py", line 719, in urlopen
    retries = retries.increment(
  File "/usr/lib/python3.9/site-packages/urllib3/util/retry.py", line 400, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/lib/python3.9/site-packages/urllib3/packages/six.py", line 702, in reraise
    raise value.with_traceback(tb)
  File "/usr/lib/python3.9/site-packages/urllib3/connectionpool.py", line 665, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3.9/site-packages/urllib3/connectionpool.py", line 421, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/lib/python3.9/site-packages/urllib3/connectionpool.py", line 416, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib64/python3.9/http/client.py", line 1347, in getresponse
    response.begin()
  File "/usr/lib64/python3.9/http/client.py", line 307, in begin
    version, status, reason = self._read_status()
  File "/usr/lib64/python3.9/http/client.py", line 276, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/tkopecek/keepal.py", line 40, in <module>
    session.get(url, verify=False, headers=headers)
  File "/usr/lib/python3.9/site-packages/requests/sessions.py", line 543, in get
    return self.request('GET', url, **kwargs)
  File "/usr/lib/python3.9/site-packages/requests/sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3.9/site-packages/requests/sessions.py", line 643, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3.9/site-packages/requests/adapters.py", line 498, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

Commit bdc2ca5 fixes this pull-request

Pull-Request has been merged by tkopecek

a year ago
Metadata