Browse Source

Reconnect automatically when bitcoind connection times out

master
James Hilliard 8 years ago
parent
commit
0a55558d9e
  1. 6
      jmclient/jmclient/jsonrpc.py

6
jmclient/jmclient/jsonrpc.py

@ -74,6 +74,7 @@ class JsonRpc(object):
body = json.dumps(obj) body = json.dumps(obj)
while True:
try: try:
self.conn.request("POST", "", body, headers) self.conn.request("POST", "", body, headers)
response = self.conn.getresponse() response = self.conn.getresponse()
@ -97,8 +98,13 @@ class JsonRpc(object):
except httplib.BadStatusLine: except httplib.BadStatusLine:
return "CONNFAILURE" return "CONNFAILURE"
except Exception as exc: except Exception as exc:
if str(exc) == "Connection reset by peer":
self.conn.connect()
continue
else:
raise JsonRpcConnectionError("JSON-RPC connection failed. Err:" + raise JsonRpcConnectionError("JSON-RPC connection failed. Err:" +
repr(exc)) repr(exc))
break
def call(self, method, params): def call(self, method, params):
""" """

Loading…
Cancel
Save