From cfdf0403328e05b12a8a737134bfa6886181e49c Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Thu, 18 Jul 2019 12:13:27 +0200 Subject: [PATCH] test: Fix AuthServiceProxy closed conn detection --- qa/rpc-tests/test_framework/authproxy.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/qa/rpc-tests/test_framework/authproxy.py b/qa/rpc-tests/test_framework/authproxy.py index 28b33e286..c3b3e7eb3 100644 --- a/qa/rpc-tests/test_framework/authproxy.py +++ b/qa/rpc-tests/test_framework/authproxy.py @@ -120,10 +120,12 @@ class AuthServiceProxy(object): return self._get_response() except Exception as e: # If connection was closed, try again. + # Python 2.7 error message was changed in https://github.com/python/cpython/pull/2825 # Python 3.5+ raises BrokenPipeError instead of BadStatusLine when the connection was reset. # ConnectionResetError happens on FreeBSD with Python 3.4. # These classes don't exist in Python 2.x, so we can't refer to them directly. - if ((isinstance(e, httplib.BadStatusLine) and e.line == "''") + if ((isinstance(e, httplib.BadStatusLine) + and e.line in ("''", "No status line received - the server has closed the connection")) or e.__class__.__name__ in ('BrokenPipeError', 'ConnectionResetError')): self.__conn.close() self.__conn.request(method, path, postdata, headers)