Get any clients ready to be used.

        :returns: Iterable of redis clients
172505
def get(self):
        
        now = time.time()
        while self._clients and self._clients[0][0] < now:
            _, (client, last_wait) = heapq.heappop(self._clients)
            connect_start = time.time()
            try:
                client.echo("test")  # reconnected if this succeeds.
                self._client_ids.remove(client.pool_id)
                yield client
            except (ConnectionError, TimeoutError):
                timer = time.time() - connect_start
                wait = min(int(last_wait * self._multiplier), self._max_wait)
                heapq.heappush(self._clients, (time.time() + wait, (client, wait)))
                log.info(
                    "%r is still down after a %s second attempt to connect. Retrying in %ss.",
                    client,
                    timer,
                    wait,
                )
681498
def _redis_client(opts):
    '''
    
    '''
    redis_host = opts.get("eauth_redis_host", "localhost")
    redis_port = opts.get("eauth_redis_port", 6379)
    try:
        return rediscluster.StrictRedisCluster(host=redis_host, port=redis_port, decode_responses=True)
    except rediscluster.exceptions.RedisClusterException as err:
        log.warning(
            'Failed to connect to redis at %s:%s - %s',
            redis_host, redis_port, err
        )
        return None
178075
def get_clients(self, limit=None, offset=None):
        
        data = {}
        if limit:
            data['limit'] = limit
        if offset:
            data['offset'] = offset
        result = self._request('GET', '/clients', data=json.dumps(data))
        return result.json()
699653
def get_redis_connection():
    
    if config.MOCK_REDIS:  # pragma: no cover
        import mockredis
        return mockredis.mock_strict_redis_client()  # pragma: no cover
    elif config.DEFENDER_REDIS_NAME:  # pragma: no cover
        try:
            cache = caches[config.DEFENDER_REDIS_NAME]
        except InvalidCacheBackendError:
            raise KeyError(INVALID_CACHE_ERROR_MSG.format(
                config.DEFENDER_REDIS_NAME))
        # every redis backend implement it own way to get the low level client
        try:
            # redis_cache.RedisCache case (django-redis-cache package)
            return cache.get_master_client()
        except AttributeError:
            # django_redis.cache.RedisCache case (django-redis package)
            return cache.client.get_client(True)
    else:  # pragma: no cover
        redis_config = parse_redis_url(config.DEFENDER_REDIS_URL)
        return redis.StrictRedis(
            host=redis_config.get('HOST'),
            port=redis_config.get('PORT'),
            db=redis_config.get('DB'),
            password=redis_config.get('PASSWORD'),
            ssl=redis_config.get('SSL'))
652659
def available_services(index = nil)
      loop do
        begin
          resp, nindex = _service.get_all(index: index)
          return [resp.keys - ['consul'], nindex] if nindex != index
        rescue Diplomat::Timeout
          # Continue waiting
        end
      end
    end
996789
def get_bindings(self):
        
        path = Client.urls['all_bindings']
        bindings = self._call(path, 'GET')
        return bindings
970500
def call_openers(self, client, clients_list):
        
        for func in self.openers:
            func(client, clients_list)
911202
def get_client(client_id):
    
    client = Client.query.get(client_id)
    if client and client.user.active:
        return client
159526
def ready(self):
        
        if self._clustering:
            return (all([c.connected for c in self._cluster.values()])
                    and len(self._cluster))
        return (self._connection and self._connection.connected)
1034062
def client(self):
        
        if self._client is None:
            self._client = client.get_client()

        return self._client
830063
def iteritems(self, pipe=None):
        """"""
        pipe = self.redis if pipe is None else pipe
        for k, v in self._data(pipe).items():
            yield k, self.cache.get(k, v)
1134893
def GetInput(self):
    """"""
    client_list = GetAllClients(token=self.token)
    logging.debug("Got %d clients", len(client_list))
    for client_group in collection.Batch(client_list, self.client_chunksize):
      for fd in aff4.FACTORY.MultiOpen(
          client_group,
          mode="r",
          aff4_type=aff4_grr.VFSGRRClient,
          token=self.token):
        if isinstance(fd, aff4_grr.VFSGRRClient):
          # Skip if older than max_age
          oldest_time = (time.time() - self.max_age) * 1e6
        if fd.Get(aff4_grr.VFSGRRClient.SchemaCls.PING) >= oldest_time:
          yield fd
689455
def GetLaunchedFlows(self, flow_type="outstanding"):
    
    result = None
    all_clients = set(self.ListAllClients())
    finished_clients = set(self.ListFinishedClients())
    outstanding_clients = all_clients - finished_clients

    if flow_type == "all":
      result = all_clients
    elif flow_type == "finished":
      result = finished_clients
    elif flow_type == "outstanding":
      result = outstanding_clients

    # Now get the flows for all these clients.
    flows = aff4.FACTORY.MultiListChildren(
        [self.urn.Add(x.Basename()) for x in result])

    return [x[0] for _, x in flows]
1328178
def client(self):
        
        if self._client is None:
            self._client = self._get_client()
        return self._client
345568
async def redis(self) -> aioredis.Redis:
        
        # Use thread-safe asyncio Lock because this method without that is not safe
        async with self._connection_lock:
            if self._redis is None:
                self._redis = await aioredis.create_redis_pool((self._host, self._port),
                                                               db=self._db, password=self._password, ssl=self._ssl,
                                                               minsize=1, maxsize=self._pool_size,
                                                               loop=self._loop, **self._kwargs)
        return self._redis
498950
def run_clients():
    
    clients = request.form.get('clients')
    if not clients:
        return jsonify({'Error': 'no clients provided'})

    result = {}
    for client_id in clients.split(','):
        if client_id not in drivers:
            init_client(client_id)
            init_timer(client_id)

        result[client_id] = get_client_info(client_id)

    return jsonify(result)
1016526
def get_clients(self):
        
        self.assert_has_permission('clients.read')

        uri = self.uri + '/oauth/clients'
        headers = self.get_authorization_headers()
        response = requests.get(uri, headers=headers)
        return response.json()['resources']