Skip to content
Snippets Groups Projects
Commit 209bc661 authored by Holger's avatar Holger
Browse files

Add disable node function

parent d0357be5
No related branches found
No related tags found
No related merge requests found
...@@ -120,6 +120,11 @@ class Nodes(list): ...@@ -120,6 +120,11 @@ class Nodes(list):
def num_retries_call_reached(self): def num_retries_call_reached(self):
return self.error_cnt_call >= self.num_retries_call return self.error_cnt_call >= self.num_retries_call
def disable_node(self):
"""Disable current node"""
if self.node is not None and self.num_retries_call >= 0:
self.node.error_cnt_call = self.num_retries_call
def increase_error_cnt(self): def increase_error_cnt(self):
"""Increase node error count for current node""" """Increase node error count for current node"""
if self.node is not None: if self.node is not None:
......
...@@ -118,8 +118,9 @@ class SteemNodeRPC(GrapheneRPC): ...@@ -118,8 +118,9 @@ class SteemNodeRPC(GrapheneRPC):
elif re.search("Could not find API", msg): elif re.search("Could not find API", msg):
if self._check_api_name(msg): if self._check_api_name(msg):
if self.nodes.working_nodes_count > 1 and self.nodes.num_retries > -1: if self.nodes.working_nodes_count > 1 and self.nodes.num_retries > -1:
self.nodes.disable_node()
self._switch_to_next_node(msg, "ApiNotSupported") self._switch_to_next_node(msg, "ApiNotSupported")
doRetry = False doRetry = True
else: else:
raise exceptions.ApiNotSupported(msg) raise exceptions.ApiNotSupported(msg)
else: else:
...@@ -151,8 +152,9 @@ class SteemNodeRPC(GrapheneRPC): ...@@ -151,8 +152,9 @@ class SteemNodeRPC(GrapheneRPC):
raise exceptions.UnhandledRPCError("Use Operation(op, appbase=True) to prevent error: " + msg) raise exceptions.UnhandledRPCError("Use Operation(op, appbase=True) to prevent error: " + msg)
elif re.search("Client returned invalid format. Expected JSON!", msg): elif re.search("Client returned invalid format. Expected JSON!", msg):
if self.nodes.working_nodes_count > 1 and self.nodes.num_retries > -1: if self.nodes.working_nodes_count > 1 and self.nodes.num_retries > -1:
self.nodes.disable_node()
self._switch_to_next_node(msg) self._switch_to_next_node(msg)
doRetry = False doRetry = True
else: else:
raise exceptions.UnhandledRPCError(msg) raise exceptions.UnhandledRPCError(msg)
elif msg: elif msg:
......
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