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)
评论列表
文章目录