def __init__(self, **kwargs): super(Client, self).__init__() self._conn = Connection(**kwargs) self._bulk = False self._bulk_keep = False self._bulk_results = None self._bulk_size = None self._bulk_size_current = None
def _connect(self, sock): host, port = sock.split(u'_') client = Connection(host=host, port=int(port), conn_timeout=self._conn_timeout, read_timeout=self._read_timeout, encoding=self._encoding, password=self._password, database=self._database) self._conns[sock] = client
def _fetch_map(self): for seed in self._seeds: conn = Connection(host=seed[0], port=seed[1], encoding='utf-8', password=self._password) try: conn.write(b'CLUSTER', b'SLOTS') return conn.read() except PyRedisError: pass finally: conn.close() raise PyRedisError('Could not get cluster info from any seed node: {0}'.format(self._seeds))
def _sentinel_connect(self, sentinel): host, port = sentinel self._conn = Connection(host=host, port=port, conn_timeout=0.1, sentinel=True) try: self.execute(u'PING') return True except PyRedisConnError: self.close() return False
def _init_conns(self, buckets, database, password, encoding, conn_timeout, read_timeout): for bucket in buckets: host, port = bucket bucketname = u'{0}_{1}'.format(host, port) self._conn_names.append(bucketname) self._conns[bucketname] = Connection(host=host, port=port, database=database, password=password, encoding=encoding, conn_timeout=conn_timeout, read_timeout=read_timeout)
def __init__(self, **kwargs): self._conn = Connection(**kwargs)