Skip to content
Snippets Groups Projects
Commit b5a7da90 authored by Holger Nahrstaedt's avatar Holger Nahrstaedt
Browse files

fix steemnoderpc for threading

parent 3ff0b890
No related branches found
No related tags found
No related merge requests found
...@@ -39,10 +39,12 @@ class SteemNodeRPC(GrapheneRPC): ...@@ -39,10 +39,12 @@ class SteemNodeRPC(GrapheneRPC):
:raises RPCError: if the server returns an error :raises RPCError: if the server returns an error
""" """
doRetry = True doRetry = True
while doRetry and self.error_cnt_call < self.num_retries_call: cnt = 0
while doRetry and cnt < self.num_retries_call:
doRetry = False doRetry = False
try: try:
# Forward call to GrapheneWebsocketRPC and catch+evaluate errors # Forward call to GrapheneWebsocketRPC and catch+evaluate errors
self.error_cnt_call = cnt
return super(SteemNodeRPC, self).rpcexec(payload) return super(SteemNodeRPC, self).rpcexec(payload)
except exceptions.RPCError as e: except exceptions.RPCError as e:
msg = exceptions.decodeRPCErrorMsg(e).strip() msg = exceptions.decodeRPCErrorMsg(e).strip()
...@@ -57,21 +59,26 @@ class SteemNodeRPC(GrapheneRPC): ...@@ -57,21 +59,26 @@ class SteemNodeRPC(GrapheneRPC):
elif re.search("Could not find API", msg): elif re.search("Could not find API", msg):
raise exceptions.NoApiWithName(msg) raise exceptions.NoApiWithName(msg)
elif re.search("Unable to acquire database lock", msg): elif re.search("Unable to acquire database lock", msg):
sleep_and_check_retries(self.num_retries_call, self.error_cnt_call, self.url, str(msg)) sleep_and_check_retries(self.num_retries_call, cnt, self.url, str(msg))
doRetry = True doRetry = True
elif re.search("Internal Error", msg): elif re.search("Internal Error", msg):
sleep_and_check_retries(self.num_retries_call, self.error_cnt_call, self.url, str(msg)) sleep_and_check_retries(self.num_retries_call, cnt, self.url, str(msg))
doRetry = True doRetry = True
elif re.search("Service Temporarily Unavailable", msg): elif re.search("Service Temporarily Unavailable", msg):
sleep_and_check_retries(self.num_retries_call, self.error_cnt_call, self.url, str(msg)) sleep_and_check_retries(self.num_retries_call, cnt, self.url, str(msg))
doRetry = True doRetry = True
elif re.search("Bad Gateway", msg): elif re.search("Bad Gateway", msg):
sleep_and_check_retries(self.num_retries_call, self.error_cnt_call, self.url, str(msg)) sleep_and_check_retries(self.num_retries_call, cnt, self.url, str(msg))
doRetry = True doRetry = True
elif msg: elif msg:
raise exceptions.UnhandledRPCError(msg) raise exceptions.UnhandledRPCError(msg)
else: else:
raise e raise e
if doRetry:
if self.error_cnt_call == 0:
cnt += 1
else:
cnt = self.error_cnt_call + 1
except Exception as e: except Exception as e:
raise e raise e
......
...@@ -53,7 +53,7 @@ class GrapheneRPC(object): ...@@ -53,7 +53,7 @@ class GrapheneRPC(object):
:param str user: Username for Authentication :param str user: Username for Authentication
:param str password: Password for Authentication :param str password: Password for Authentication
:param int num_retries: Try x times to num_retries to a node on disconnect, -1 for indefinitely :param int num_retries: Try x times to num_retries to a node on disconnect, -1 for indefinitely
:param int num_retries_call: Repeat num_retries_call times a rpccall on node error (default is 5) :param int num_retries_call: Repeat num_retries_call times a rpc call on node error (default is 5)
Available APIs Available APIs
* database * database
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment