mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-18 22:35:39 +01:00
Merge #18596: test: Try once more when RPC connection fails on Windows
fab9899204test: Try once more when RPC connection fails on Windows (MarcoFalke)faa655731etest: Document why connection is re-constructed on windows (MarcoFalke)fa9f4f663ctest: Remove python 3.4 workaround (MarcoFalke)fae760f2b2cirrus: Bump freebsd to 12.1 (MarcoFalke) Pull request description: Fixes: #18548 ACKs for top commit: hebasto: ACKfab9899204, I have reviewed the code and it looks OK, I agree it can be merged. Tree-SHA512: c4e9ed8d995b63a820ca66984f152ac216c83ba1f318b61b15c6d375c0e936c08f6bc3d38c255dddf3ee8952f848c7ababf684854e07a7c1b1d8504e6b7208ba
This commit is contained in:
@@ -101,23 +101,26 @@ class AuthServiceProxy():
|
||||
if os.name == 'nt':
|
||||
# Windows somehow does not like to re-use connections
|
||||
# TODO: Find out why the connection would disconnect occasionally and make it reusable on Windows
|
||||
# Avoid "ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine"
|
||||
self._set_conn()
|
||||
try:
|
||||
self.__conn.request(method, path, postdata, headers)
|
||||
return self._get_response()
|
||||
except http.client.BadStatusLine as e:
|
||||
if e.line == "''": # if connection was closed, try again
|
||||
except (BrokenPipeError, ConnectionResetError):
|
||||
# Python 3.5+ raises BrokenPipeError when the connection was reset
|
||||
# ConnectionResetError happens on FreeBSD
|
||||
self.__conn.close()
|
||||
self.__conn.request(method, path, postdata, headers)
|
||||
return self._get_response()
|
||||
except OSError as e:
|
||||
retry = (
|
||||
'[WinError 10053] An established connection was aborted by the software in your host machine' in str(e))
|
||||
if retry:
|
||||
self.__conn.close()
|
||||
self.__conn.request(method, path, postdata, headers)
|
||||
return self._get_response()
|
||||
else:
|
||||
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 get_request(self, *args, **argsn):
|
||||
AuthServiceProxy.__id_count += 1
|
||||
|
||||
Reference in New Issue
Block a user