# Path: aredis/utils.py
# _C_EXTENSION_SPEEDUP = False
#     _C_EXTENSION_SPEEDUP = True
# LOOP_DEPRECATED = sys.version_info >= (3, 8)
#     BLOCKED = 'blocked'
#     ALL_NODES = 'all-nodes'
#     ALL_MASTERS = 'all-masters'
#     RANDOM = 'random'
#     SLOT_ID = 'slot-id'
# def b(x):
# def nativestr(x):
# def iteritems(x):
# def iterkeys(x):
# def itervalues(x):
# def ban_python_version_lt(min_version):
#     def decorator(func):
#         def _inner(*args, **kwargs):
#     def __init__(self):
#     def set(self, value):
#     def get(self):
# def string_keys_to_dict(key_string, callback):
# def list_keys_to_dict(key_list, callback):
# def dict_merge(*dicts):
# def bool_ok(response):
# def list_or_args(keys, args):
# def int_or_none(response):
# def pairs_to_dict(response):
# def merge_result(res):
# def first_key(res):
# def blocked_command(self, command):
# def clusterdown_wrapper(func):
#     async def inner(*args, **kwargs):
#     def _crc16(data):
#     def _hash_slot(key):
# class dummy:
# class NodeFlag:
# 
# Path: aredis/exceptions.py
# class ConnectionError(RedisError):
#     pass
# 
# class RedisClusterException(Exception):
#     pass


import random
from aredis.utils import (b, hash_slot)
from aredis.exceptions import (ConnectionError,
                               RedisClusterException)
        from aredis.client import StrictRedis
    async def initialize(self):
        """
        Initializes the slots cache by asking all startup nodes what the
        current cluster configuration is.

        TODO: Currently the last node will have the last say about how the configuration is setup.
        Maybe it should stop to try after it have correctly covered all slots or when one node is reached
        and it could execute CLUSTER SLOTS command.
        """
        nodes_cache = {}
        tmp_slots = {}

        all_slots_covered = False
        disagreements = []
        startup_nodes_reachable = False

        nodes = self.orig_startup_nodes

        # With this option the client will attempt to connect to any of the previous set of nodes instead of the original set of nodes
        if self.nodemanager_follow_cluster:
            nodes = self.startup_nodes

        for node in nodes:
            try:
                r = self.get_redis_link(host=node['host'], port=node['port'])
                cluster_slots = await r.cluster_slots()
                startup_nodes_reachable = True
            except ConnectionError:
                continue
            except Exception:

# Path: aredis/utils.py
# _C_EXTENSION_SPEEDUP = False
#     _C_EXTENSION_SPEEDUP = True
# LOOP_DEPRECATED = sys.version_info >= (3, 8)
#     BLOCKED = 'blocked'
#     ALL_NODES = 'all-nodes'
#     ALL_MASTERS = 'all-masters'
#     RANDOM = 'random'
#     SLOT_ID = 'slot-id'
# def b(x):
# def nativestr(x):
# def iteritems(x):
# def iterkeys(x):
# def itervalues(x):
# def ban_python_version_lt(min_version):
#     def decorator(func):
#         def _inner(*args, **kwargs):
#     def __init__(self):
#     def set(self, value):
#     def get(self):
# def string_keys_to_dict(key_string, callback):
# def list_keys_to_dict(key_list, callback):
# def dict_merge(*dicts):
# def bool_ok(response):
# def list_or_args(keys, args):
# def int_or_none(response):
# def pairs_to_dict(response):
# def merge_result(res):
# def first_key(res):
# def blocked_command(self, command):
# def clusterdown_wrapper(func):
#     async def inner(*args, **kwargs):
#     def _crc16(data):
#     def _hash_slot(key):
# class dummy:
# class NodeFlag:
# 
# Path: aredis/exceptions.py
# class ConnectionError(RedisError):
#     pass
# 
# class RedisClusterException(Exception):
#     pass


# Path: aredis/nodemanager.py
import random
from aredis.utils import (b, hash_slot)
from aredis.exceptions import (ConnectionError,
                               RedisClusterException)
        from aredis.client import StrictRedis

    async def initialize(self):
        """
        Initializes the slots cache by asking all startup nodes what the
        current cluster configuration is.

        TODO: Currently the last node will have the last say about how the configuration is setup.
        Maybe it should stop to try after it have correctly covered all slots or when one node is reached
        and it could execute CLUSTER SLOTS command.
        """
        nodes_cache = {}
        tmp_slots = {}

        all_slots_covered = False
        disagreements = []
        startup_nodes_reachable = False

        nodes = self.orig_startup_nodes

        # With this option the client will attempt to connect to any of the previous set of nodes instead of the original set of nodes
        if self.nodemanager_follow_cluster:
            nodes = self.startup_nodes

        for node in nodes:
            try:
                r = self.get_redis_link(host=node['host'], port=node['port'])
                cluster_slots = await r.cluster_slots()
                startup_nodes_reachable = True
            except ConnectionError:
                continue
            except Exception:

                raise RedisClusterException('ERROR sending "cluster slots" command to redis server: {0}'.format(node))