client.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:raiden 作者: raiden-network 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号