Client.py 文件源码

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

项目:lib9 作者: Jumpscale 项目源码 文件源码
def __init__(self, host, port=6379, password="", db=0, ssl=True, timeout=None, testConnectionAttempts=3):
        super().__init__(timeout=timeout)

        socket_timeout = (timeout + 5) if timeout else 15
        socket_keepalive_options = dict()
        if hasattr(socket, 'TCP_KEEPIDLE'):
            socket_keepalive_options[socket.TCP_KEEPIDLE] = 1
        if hasattr(socket, 'TCP_KEEPINTVL'):
            socket_keepalive_options[socket.TCP_KEEPINTVL] = 1
        if hasattr(socket, 'TCP_KEEPIDLE'):
            socket_keepalive_options[socket.TCP_KEEPIDLE] = 1
        self._redis = redis.Redis(host=host, port=port, password=password, db=db, ssl=ssl,
                                  socket_timeout=socket_timeout,
                                  socket_keepalive=True, socket_keepalive_options=socket_keepalive_options)
        self.container = ContainerManager(self)
        self.bridge = BridgeManager(self)
        self.disk = DiskManager(self)
        self.btrfs = BtrfsManager(self)
        self.zerotier = ZerotierManager(self)
        self.kvm = KvmManager(self)
        self.logger = Logger(self)
        self.nft = Nft(self)
        self.config = Config(self)
        self.aggregator = AggregatorManager(self)

        if testConnectionAttempts:
            for _ in range(testConnectionAttempts):
                try:
                    self.ping()
                except:
                    pass
                else:
                    return
            raise ConnectionError("Could not connect to remote host %s" % host)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号