Fix an error reporting bug due to BrokenPipeError and ConnectionResetError not existing in Python 2.
refs #2263 Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
parent
c5229b5603
commit
80cbdbc749
|
@ -118,19 +118,18 @@ class AuthServiceProxy(object):
|
||||||
try:
|
try:
|
||||||
self.__conn.request(method, path, postdata, headers)
|
self.__conn.request(method, path, postdata, headers)
|
||||||
return self._get_response()
|
return self._get_response()
|
||||||
except httplib.BadStatusLine as e:
|
except Exception as e:
|
||||||
if e.line == "''": # if connection was closed, try again
|
# If connection was closed, try again.
|
||||||
|
# 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 == "''")
|
||||||
|
or e.__class__.__name__ in ('BrokenPipeError', 'ConnectionResetError')):
|
||||||
self.__conn.close()
|
self.__conn.close()
|
||||||
self.__conn.request(method, path, postdata, headers)
|
self.__conn.request(method, path, postdata, headers)
|
||||||
return self._get_response()
|
return self._get_response()
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
except (BrokenPipeError,ConnectionResetError):
|
|
||||||
# Python 3.5+ raises BrokenPipeError instead of BadStatusLine when the connection was reset
|
|
||||||
# ConnectionResetError happens on FreeBSD with Python 3.4
|
|
||||||
self.__conn.close()
|
|
||||||
self.__conn.request(method, path, postdata, headers)
|
|
||||||
return self._get_response()
|
|
||||||
|
|
||||||
def __call__(self, *args):
|
def __call__(self, *args):
|
||||||
AuthServiceProxy.__id_count += 1
|
AuthServiceProxy.__id_count += 1
|
||||||
|
|
Loading…
Reference in New Issue