def check_node_connection(func):
""" A decorator to reconnect if the connection to the node is lost."""
def retry_on_disconnect(self, *args, **kwargs):
for i, timeout in enumerate(timeout_two_stage(10, 3, 10)):
try:
result = func(self, *args, **kwargs)
if i > 0:
log.info('Client reconnected')
return result
except (requests.exceptions.ConnectionError, InvalidReplyError):
log.info(
'Timeout in eth client connection to {}. Is the client offline? Trying '
'again in {}s.'.format(self.transport.endpoint, timeout)
)
gevent.sleep(timeout)
return retry_on_disconnect
评论列表
文章目录