Skip to content

Commit da4926b

Browse files
ryanofskyMarcoFalke
authored andcommitted
[qa] Add more helpful RPC timeout message
Replace previous timeout('timed out',) exception with more detailed error. Github-Pull: bitcoin#9077 Rebased-From: e89614b
1 parent 1d4c884 commit da4926b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

qa/rpc-tests/test_framework/authproxy.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import decimal
4343
import json
4444
import logging
45+
import socket
4546
try:
4647
import urllib.parse as urlparse
4748
except ImportError:
@@ -157,7 +158,15 @@ def _batch(self, rpc_call_list):
157158
return self._request('POST', self.__url.path, postdata.encode('utf-8'))
158159

159160
def _get_response(self):
160-
http_response = self.__conn.getresponse()
161+
try:
162+
http_response = self.__conn.getresponse()
163+
except socket.timeout as e:
164+
raise JSONRPCException({
165+
'code': -344,
166+
'message': '%r RPC took longer than %f seconds. Consider '
167+
'using larger timeout for calls that take '
168+
'longer to return.' % (self._service_name,
169+
self.__conn.timeout)})
161170
if http_response is None:
162171
raise JSONRPCException({
163172
'code': -342, 'message': 'missing HTTP response from server'})

0 commit comments

Comments
 (0)