� J�g��� �2�ddlZddlZddlZddlZddlZddlZddlmZmZm Z m Z m Z m Z m Z mZmZmZmZmZddlmZmZddlmZmZmZddlmZddlmZmZmZm Z ddl!m"Z"ddl#m$Z$dd l%m&Z&dd l'm(Z(m)Z)m*Z*dd l+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4dd l5m6Z6m7Z7dd l8m9Z9m:Z:ddl;m<Z<ddl=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLddlMmNZNmOZOmPZPddlQmRZRmSZSmTZTmUZUmVZVedeWde de edf��ZXGd�de��ZYGd�de*e0e7��ZZGd�d��Z[Gd�d��Z\Gd�de*e0e7��Z]e,D]GZ^e^�_dd���`��Z^e^dkr�1eae]e^e2e^�����HGd �d!��ZbdS)"�N) �Any�Callable�Deque�Dict� Generator�List�Mapping�Optional�Tuple�Type�TypeVar�Union)�AsyncCommandsParser�Encoder)�_RedisCallbacks�_RedisCallbacksRESP2�_RedisCallbacksRESP3)�ResponseCallbackT)� Connection� DefaultParser� SSLConnection� parse_url��Lock)�Retry)�default_backoff)�EMPTY_RESPONSE� NEVER_DECODE� AbstractRedis) �PIPELINE_BLOCKED_COMMANDS�PRIMARY�REPLICA�SLOT_ID�AbstractRedisCluster� LoadBalancer�block_pipeline_command� get_node_name�parse_cluster_slots)� READ_COMMANDS�AsyncRedisClusterCommands)�REDIS_CLUSTER_HASH_SLOTS�key_slot)�CredentialProvider)�AskError�BusyLoadingError�ClusterCrossSlotError�ClusterDownError� ClusterError�ConnectionError� DataError�MasterDownError�MaxConnectionsError� MovedError�RedisClusterException� ResponseError�SlotNotCoveredError� TimeoutError� TryAgainError)�AnyKeyT� EncodableT�KeyT)�deprecated_function� dict_merge�get_lib_version�safe_str� str_if_bytes� TargetNodesT� ClusterNodec �>�eZdZeejeeee e e d���ZdS)� ClusterParser)�ASK� CLUSTERDOWN� CROSSSLOT� MASTERDOWN�MOVED�TRYAGAINN) �__name__� __module__� __qualname__rAr�EXCEPTION_CLASSESr.r1r0r5r7r<���e/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/redis/asyncio/cluster.pyrHrHOsD������"� ��'��+�.�)��%�  � � � ���rTrHcR�(�eZdZdZedededdfd���ZdZdddd d d d d d ddddddde ��ddd ddd ddddd ddddd dddddf&de ede ee fde e ddedede de de de de ee fde ed e ed!e ed"e ed#e ed$e ed%e ed&ed'ed(ed)ed*e ed+ed,e ee e e effd-e ed.e d/d0e e eed1ed2e ed3e ed4ed5e ed6ed7e ed8e ejd9e ed:e e d;e eeee fgeee ffddfNd<�Zd|d=�Zd}d>�Zed?d@dA�B��d}dC���Zd|dD�Zd~dH�Zde eddffdI�Z!dJZ"e#j$e%j&fdKedLeddfdM�Z'dNe(ddfdO�Z)de dfdP�Z*de dfdQ�Z+de dfdR�Z,ddS�Z-ddT�Z.d�dV�Z/ d�de ede e dWe ede dfdX�Z0 d�dYedZede dfd[�Z1dYe2de fd\�Z3de4fd]�Z5de6ee effd^�Z7de d/fd_�Z8d�d`�Z9daedbe:ddfdc�Z;ddd�daedeedfe ede dfdg�Z<daedeede fdh�Z=diedefdj�Z>diede dfdk�Z?dee2dedefdl�Z@dmddee eAe2fdedefdn�ZB d�doe edpe eddqfdr�ZC d�dteAdue edvedwedxe edye eeDdzedeDfd{�ZEdS)�� RedisClusteraG Create a new RedisCluster client. Pass one of parameters: - `host` & `port` - `startup_nodes` | Use ``await`` :meth:`initialize` to find cluster nodes & create connections. | Use ``await`` :meth:`close` to disconnect connections & close client. Many commands support the target_nodes kwarg. It can be one of the :attr:`NODE_FLAGS`: - :attr:`PRIMARIES` - :attr:`REPLICAS` - :attr:`ALL_NODES` - :attr:`RANDOM` - :attr:`DEFAULT_NODE` Note: This client is not thread/process/fork safe. :param host: | Can be used to point to a startup node :param port: | Port used if **host** is provided :param startup_nodes: | :class:`~.ClusterNode` to used as a startup node :param require_full_coverage: | When set to ``False``: the client will not require a full coverage of the slots. However, if not all slots are covered, and at least one node has ``cluster-require-full-coverage`` set to ``yes``, the server will throw a :class:`~.ClusterDownError` for some key-based commands. | When set to ``True``: all slots must be covered to construct the cluster client. If not all slots are covered, :class:`~.RedisClusterException` will be thrown. | See: https://redis.io/docs/manual/scaling/#redis-cluster-configuration-parameters :param read_from_replicas: | Enable read from replicas in READONLY mode. You can read possibly stale data. When set to true, read commands will be assigned between the primary and its replications in a Round-Robin manner. :param reinitialize_steps: | Specifies the number of MOVED errors that need to occur before reinitializing the whole cluster topology. If a MOVED error occurs and the cluster does not need to be reinitialized on this current error handling, only the MOVED slot will be patched with the redirected node. To reinitialize the cluster on every MOVED error, set reinitialize_steps to 1. To avoid reinitializing the cluster on moved errors, set reinitialize_steps to 0. :param cluster_error_retry_attempts: | Number of times to retry before raising an error when :class:`~.TimeoutError` or :class:`~.ConnectionError` or :class:`~.ClusterDownError` are encountered :param connection_error_retry_attempts: | Number of times to retry before reinitializing when :class:`~.TimeoutError` or :class:`~.ConnectionError` are encountered. The default backoff strategy will be set if Retry object is not passed (see default_backoff in backoff.py). To change it, pass a custom Retry object using the "retry" keyword. :param max_connections: | Maximum number of connections per node. If there are no free connections & the maximum number of connections are already created, a :class:`~.MaxConnectionsError` is raised. This error may be retried as defined by :attr:`connection_error_retry_attempts` :param address_remap: | An optional callable which, when provided with an internal network address of a node, e.g. a `(host, port)` tuple, will return the address where the node is reachable. This can be used to map the addresses at which the nodes _think_ they are, to addresses at which a client may reach them, such as when they sit behind a proxy. | Rest of the arguments will be passed to the :class:`~redis.asyncio.connection.Connection` instances when created :raises RedisClusterException: if any arguments are invalid or unknown. Eg: - `db` != 0 or None - `path` argument for unix socket connection - none of the `host`/`port` & `startup_nodes` were provided �url�kwargs�returnc ��|�t|����|�dd��turd|d<|di|��S)a� Return a Redis client object configured from the given URL. For example:: redis://[[username]:[password]]@localhost:6379/0 rediss://[[username]:[password]]@localhost:6379/0 Three URL schemes are supported: - `redis://` creates a TCP socket connection. See more at: <https://www.iana.org/assignments/uri-schemes/prov/redis> - `rediss://` creates a SSL wrapped TCP socket connection. See more at: <https://www.iana.org/assignments/uri-schemes/prov/rediss> The username, password, hostname, path and all querystring values are passed through ``urllib.parse.unquote`` in order to replace any percent-encoded values with their corresponding characters. All querystring options are cast to their appropriate Python types. Boolean arguments can be specified with string values "True"/"False" or "Yes"/"No". Values that cannot be properly cast cause a ``ValueError`` to be raised. Once parsed, the querystring arguments and keyword arguments are passed to :class:`~redis.asyncio.connection.Connection` when created. In the case of conflicting arguments, querystring arguments are used. �connection_classNT�sslrS)�updater�popr)�clsrXrYs rU�from_urlzRedisCluster.from_url�sQ��8 � � �i��n�n�%�%�%� �:�:�(�$� /� /�=� @� @� �F�5�M��s�}�}�V�}�}�rT)� _initialize�_lock�cluster_error_retry_attempts� command_flags�commands_parser�connection_error_retry_attempts�connection_kwargs�encoder� node_flags� nodes_manager�read_from_replicas�reinitialize_counter�reinitialize_steps�response_callbacks�result_callbacksNi�TF���rzredis-pyzutf-8�strict�required��host�port� startup_nodesrF�require_full_coveragerlrnrdrg�max_connections�db�path�credential_provider�username�password� client_name�lib_name� lib_version�encoding�encoding_errors�decode_responses�health_check_interval�socket_connect_timeout�socket_keepalive�socket_keepalive_options�socket_timeout�retryr�retry_on_errorr]� ssl_ca_certs� ssl_ca_data� ssl_cert_reqs� ssl_certfile�ssl_check_hostname� ssl_keyfile�ssl_min_version� ssl_ciphers�protocol� address_remapc' ���| rtd���| rtd���|r|s|std���id| �dt�dt�d| �d| �d |�d |�d |�d |�d |�d|�d|�d|�d|�d|�d|�d|�||%d��}'|r$|'�t|||| |!|"|#|$d� ��|r |j|'d<||_|s|s|dkri|ptt��|��|_|sttg}|j� |��|'�d|ji��tj ��|'d<|'�d��dvr!|'d�t��n |'d�t ��|'|_|r:g}(|D]2})|(�t'|)j|)jfi|j�����3|(}ng}|r(|r&|�t'||fi|j����t-|||'|&���|_t1|||��|_||_||_||_||_d|_t?��|_ |j!j"� ��|_#|j!j$� ��|_%|'d|_&|j!j'� ��|_(d�|j(d<d |_)d|_*dS)!Nz/Argument 'db' must be 0 or None in cluster modez3Unix domain socket is not supported in cluster modea1RedisCluster requires at least one node to discover the cluster. Please provide one of the following or use RedisCluster.from_url: - host and port: RedisCluster(host="localhost", port=6379) - startup_nodes: RedisCluster(startup_nodes=[ClusterNode("localhost", 6379), ClusterNode("localhost", 6380)])r{r\� parser_classr~rr�r�r�r�r�r�r�r�r�r�r�r�)r�r�) r\r�r�r�r�r�r�r�r��redis_connect_funcrr�ror�)�3rr�r�c�f�tt|�����dfi|��S)Nr)r(�list�values)�cmd�resrYs rU�<lambda>z'RedisCluster.__init__.<locals>.<lambda>�s6��':��S�Z�Z�\�\�"�"�1�%�(�(�)/�(�(�rT� CLUSTER SLOTST)+r8rrHr^r� on_connectr�rrr3r;�update_supported_errorsr�copy�getrrrh�appendrFrwrx� NodesManagerrkrrirlrnrdrgrmrrf� __class__� NODE_FLAGSrj� COMMAND_FLAGSrero�RESULT_CALLBACKSrprbrc)*�selfrwrxryrzrlrnrdrgr{r|r}r~rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r]r�r�r�r�r�r�r�r�r�r�rY� passed_nodes�nodes* rU�__init__zRedisCluster.__init__�s>��\ � �'�A��� � � �'�E��� �� �D� �-� �'�S��� �" � ��" � � �" � �M�" � "�#6� " � �� " � ��" � �;�" � ��" � �;�" � ��" � ��" � � 0�" � $�%:�!" �" %�&<�#" �$ � 0�%" �& '�(@�'" �( �n�)" �*� �-" �" �" ��2 � � �M�M�(5�$0�#.�%2�$0�*<�#.�'6�#.� � � � � � � ;�+/�?�F�'� (��� � � 1�N� 1�&E��&I�&I���%��!�!�#B�#�#�D�J�"� A�"1�<�!@�� �J� .� .�~� >� >� >� �M�M�7�D�J�/� 0� 0� 0�'6�';�'=�'=��#�$� �:�:�j� !� !�X� -� -� �'� (� /� /�0D� E� E� E� E� �'� (� /� /�0D� E� E� E�!'��� � ��L�%� � ���#�#��� �4�9�O�O��8N�O�O�����)�M�M��M� � T�D� T� � � ��T�4�!R�!R�4�;Q�!R�!R� S� S� S�)� � !� �'�  � � ��� �x��:J�K�K�� �"4���"4���,H��)�/N��,�$%��!�2�4�4����.�3�8�8�:�:���!�^�9�>�>�@�@���"(�)=�">��� $�� ?� D� D� F� F��� � � ��o�.�  ���-1�� � � rTc��K�|jr�|jstj��|_|j4�d{V��|jr� |j����d{V��|j�|jj���d{V��d|_nN#t$rA|j� ���d{V��|j� d���d{V���wxYwddd���d{V��n#1�d{V��swxYwY|S)zJGet all nodes from startup nodes & creates connections if not initialized.NFry) rbrc�asynciorrk� initializerf� default_node� BaseException�aclose�r�s rUr�zRedisCluster.initialize�s����� � � ��:� ,�$�\�^�^�� ��z� � � � � � � � ��#� � �"�0�;�;�=�=�=�=�=�=�=�=�=�"�2�=�=� �.�;����������,1��(�(��(����"�0�7�7�9�9�9�9�9�9�9�9�9�"�0�7�7��H�H�H�H�H�H�H�H�H������ � � � � � � � � � � � � � � � � � � � � � � ���� � � � �� s*�C0�AB�C0�A C�C0�0 C:�=C:c��XK�|js�|jstj��|_|j4�d{V��|jsFd|_|j����d{V��|j�d���d{V��ddd���d{V��dS#1�d{V��swxYwYdSdS)z.Close all connections & client if initialized.NTry)rbrcr�rrkr�r�s rUr�zRedisCluster.aclose�s������� E��:� ,�$�\�^�^�� ��z� E� E� E� E� E� E� E� E��'�E�'+�D�$��,�3�3�5�5�5�5�5�5�5�5�5��,�3�3�O�D�D�D�D�D�D�D�D�D�  E� E� E� E� E� E� E� E� E� E� E� E� E� E� E� E� E� E� E� E� E� E� E� E���� E� E� E� E� E� E� E� Es�AB� B!�$B!z5.0.0zUse aclose() instead�close)�version�reason�namec��>K�|����d{V��dS)z.alias for aclose() for backwards compatibilityN�r�r�s rUr�zRedisCluster.close�s.�����k�k�m�m���������rTc��:K�|����d{V��S�N�r�r�s rU� __aenter__zRedisCluster.__aenter__��(�����_�_�&�&�&�&�&�&�&�&�&rT�exc_type� exc_value� tracebackc��>K�|����d{V��dSr�r��r�r�r�r�s rU� __aexit__zRedisCluster.__aexit__�s,�����k�k�m�m���������rTc�N�|������Sr��r�� __await__r�s rUr�zRedisCluster.__await__������� � �*�*�,�,�,rTzUnclosed RedisCluster client�_warn�_grlc���t|d��r_|jsZ||j�d|��t|��� ||jd�}|���|��dS#t $rYdSwxYwdSdS)Nrb� ��source��client�message)�hasattrrb� _DEL_MESSAGE�ResourceWarning�call_exception_handler� RuntimeError)r�r�r��contexts rU�__del__zRedisCluster.__del__�s��� �4�� '� '� ��0@� � �E�T�&�1�1��1�1�?�4� P� P� P� P� �%)�d�6G�H�H������-�-�g�6�6�6�6�6��� � � ���� ����  � � � s�'A� A-�,A-� connectionc���K�|����d{V��|�d���d{V��t|����d{V����dkrt d���dS)N�READONLY�OKzREADONLY command failed)r�� send_commandrD� read_responser3�r�r�s rUr�zRedisCluster.on_connect�s������#�#�%�%�%�%�%�%�%�%�%��%�%�j�1�1�1�1�1�1�1�1�1� �j�6�6�8�8�8�8�8�8�8�8� 9� 9�T� A� A�!�";�<�<� <� B� ArTc�X�t|jj�����S)zGet all nodes of the cluster.)r�rk� nodes_cacher�r�s rU� get_nodeszRedisCluster.get_nodes�s"���D�&�2�9�9�;�;�<�<�<rTc�@�|j�t��S)z%Get the primary nodes of the cluster.)rk�get_nodes_by_server_typer!r�s rU� get_primarieszRedisCluster.get_primaries�����!�:�:�7�C�C�CrTc�@�|j�t��S)z%Get the replica nodes of the cluster.)rkr�r"r�s rU� get_replicaszRedisCluster.get_replicas�r�rTc�|�tjt|jj�������S)z!Get a random node of the cluster.)�random�choicer�rkr�r�r�s rU�get_random_nodezRedisCluster.get_random_node�s,���}�T�$�"4�"@�"G�"G�"I�"I�J�J�K�K�KrTc��|jjS)z#Get the default node of the client.)rkr�r�s rU�get_default_nodezRedisCluster.get_default_node�s���!�.�.rTr�c�v�|r|�|j���std���||j_dS)z� Set the default node of the client. :raises DataError: if None is passed or node does not exist in cluster. �� node_namez1The requested node does not exist in the cluster.N)�get_noder�r4rkr�)r�r�s rU�set_default_nodezRedisCluster.set_default_node�sE�� � Q�4�=�=�4�9�=�=�=� Q��O�P�P� P�*.���'�'�'rTr�c�:�|j�|||��S)z&Get node by (host, port) or node_name.)rkr��r�rwrxr�s rUr�zRedisCluster.get_node�s���!�*�*�4��y�A�A�ArT�key�replicac���|�|��}|jj�|��}|st d|�d����|r(t |jj|��dkrdSd}nd}||S)aG Get the cluster node corresponding to the provided key. :param key: :param replica: | Indicates if a replica should be returned | None will returned if no replica holds this key :raises SlotNotCoveredError: if the key is not covered by any slot. �Slot "z " is not covered by the cluster.rvN�r)�keyslotrk� slots_cacher�r:�len)r�r�r��slot� slot_cache�node_idxs rU�get_node_from_keyzRedisCluster.get_node_from_key�s����|�|�C� � ���'�3�7�7��=�=� �� W�%�&U�t�&U�&U�&U�V�V� V� � ��4�%�1�$�7�8�8�1�<�<��t��H�H��H��(�#�#rTc�P�t|j�|����S)z� Find the keyslot for a given key. See: https://redis.io/docs/manual/scaling/#redis-cluster-data-sharding )r,ri�encode)r�r�s rUrzRedisCluster.keyslots"�� �� �+�+�C�0�0�1�1�1rTc��|jS)z%Get the encoder object of the client.)rir�s rU� get_encoderzRedisCluster.get_encoders ���|�rTc��|jS)zGGet the kwargs passed to :class:`~redis.asyncio.connection.Connection`.)rhr�s rU�get_connection_kwargsz"RedisCluster.get_connection_kwargs"s ���%�%rTc��|jSr�)r�r�s rU� get_retryzRedisCluster.get_retry&s ���z�rTc��||_|���D]/}|j�d|i��|jD] }||_� �0dS)Nr�)r�r�rhr^� _connections)r�r�r��conns rU� set_retryzRedisCluster.set_retry)sh���� ��N�N�$�$� #� #�D� � "� )� )�7�E�*:� ;� ;� ;��)� #� #��"�� � � #� #� #rT�command�callbackc��||j|<dS)zSet a custom response callback.N)ro)r�rrs rU�set_response_callbackz"RedisCluster.set_response_callback0s��+3����(�(�(rT)� node_flag�argsrc���K�|s|j�|��}||jv�r||jjkr |jjgS||jjkr|j�t��S||jj kr|j�t��S||jj kr+t|jj�����S||jjkr>t#jt|jj�������gS|j�|j|g|�R��d{V��|jo|t,v��gSr�)rer�rjr�� DEFAULT_NODErkr�� PRIMARIESr�r!�REPLICASr"� ALL_NODESr�r�r��RANDOMr�r��get_node_from_slot�_determine_slotrlr))r�rrrs rU�_determine_nodeszRedisCluster._determine_nodes4si���� � 8��*�.�.�w�7�7�I� ��� '� '��D�N�7�7�7��*�7�8�8��D�N�4�4�4��)�B�B�7�K�K�K��D�N�3�3�3��)�B�B�7�K�K�K��D�N�4�4�4��D�.�:�A�A�C�C�D�D�D��D�N�1�1�1�� �d�4�+=�+I�+P�+P�+R�+R�&S�&S�T�T�U�U� � � 1� 1�*�d�*�7�:�T�:�:�:�:�:�:�:�:�:��'�D�G�}�,D� � � � rTc���K��j�|��tkrt|d��S|���dvrft |��dkrt d|g|�R�����|ddt|d��z�}|stjdt��Sn]�j j |g|�R��d{V��}|sB|���dvrtjdt��St d|�����t |��dkr�� |d��S�fd�|D��}t |��dkrt |�d ����|� ��S) Nr)�EVAL�EVALSHArvzInvalid args in command: r)�FCALL�FCALL_ROz�No way to dispatch this command to Redis Cluster. Missing key. You can execute the command by specifying target nodes. Command: c�:��h|]}��|����SrS)r)�.0r�r�s �rU� <setcomp>z/RedisCluster._determine_slot.<locals>.<setcomp>�s%���3�3�3�s����c�"�"�3�3�3rTz) - all keys must map to the same key slot)rer�r#�int�upperrr8r�� randranger+rf�get_keysrr_)r�rr�keys�slotss` rUr!zRedisCluster._determine_slotVs������ � � !� !�'� *� *�g� 5� 5��t�A�w�<�<� � �=�=�?�?�1� 1� 1��4�y�y�1�}�}�+�@��/?�$�/?�/?�@�@������A��D��G� � �,�,�-�D�� E��'��+C�D�D�D� E�7��-�6�w�F��F�F�F�F�F�F�F�F�F�D�� ��=�=�?�?�&;�;�;�!�+�A�/G�H�H�H�+�6�/3�6�6���� �t�9�9��>�>��<�<��Q��(�(� (�4�3�3�3�d�3�3�3�� �u�:�:��?�?�'��E�E�E��� ��y�y�{�{�rT� target_nodesc�>�t|t��o||jvSr�)� isinstance�strrj)r�r1s rU� _is_node_flagzRedisCluster._is_node_flag�s���,��,�,�P����1P�PrTc��t|t��r|}not|t��r|g}nVt|t��r"t|�����}nt dt |�������|S)Nz�target_nodes type can be one of the following: node_flag (PRIMARIES, REPLICAS, RANDOM, ALL_NODES),ClusterNode, list<ClusterNode>, or dict<any, ClusterNode>. The passed type is )r3r�rF�dictr�� TypeError�type)r�r1�nodess rU�_parse_target_nodesz RedisCluster._parse_target_nodes�s��� �l�D� )� )� � �E�E� � �k� 2� 2� �!�N�E�E� � �d� +� +� ���,�,�.�.�/�/�E�E��;�'+�<�&8�&8�;�;��� � � rTc ��d���K��d}g}d}�j}��dd��}|r.��|��s��|��}d}d}d|z}t |��D�]�} �jr_�����d{V��t|��dkr2|d����kr�� �� |s(�j �d|i��d{V��}|std��d ����t|��dkrN�j |dg��Ri����d{V��} |�j vr$�j |||dj| ifi���cS| cSd �|D��} tj���fd �|D����d{V��} |�j vr2�j ||t#t%| | ����fi���cSt#t%| | ����cS#t&$r3} |dkr&t)| ���jjvr |dz}Yd} ~ ���| �d} ~ wwxYwdS) a| Execute a raw command on the appropriate cluster node or target_nodes. It will retry the command as specified by :attr:`cluster_error_retry_attempts` & then raise an exception. :param args: | Raw command args :param kwargs: - target_nodes: :attr:`NODE_FLAGS` or :class:`~.ClusterNode` or List[:class:`~.ClusterNode`] or Dict[Any, :class:`~.ClusterNode`] - Rest of the kwargs are passed to the Redis connection :raises RedisClusterException: if target_nodes is not provided & the command can't be mapped to a slot rFr1NTrr�!No targets were found to execute � command onc��g|] }|j�� SrS�r��r)r�s rU� <listcomp>z0RedisCluster.execute_command.<locals>.<listcomp>�s��?�?�?�$�D�I�?�?�?rTc3�^�K�|]'}tj�j|g��Ri�����V��(dSr�)r�� create_task�_execute_command)r)r�rrYr�s ���rU� <genexpr>z/RedisCluster.execute_command.<locals>.<genexpr>�sf�������!%�$�/� 5�� 5�d� L�T� L� L� L�V� L� L��������rT)rdr_r5r;�rangerbr�rr��replace_default_noder"r8rErpr�r��gatherr7�zip� Exceptionr9r��ERRORS_ALLOW_RETRY)r�rrYrr1�target_nodes_specified�retry_attempts�passed_targets�execute_attempts�_�retr/r��es``` rU�execute_commandzRedisCluster.execute_command�sy�������$�q�'��� �!&���:�����N�D�9�9�� � �$�"4�"4�^�"D�"D� ��3�3�N�C�C�L�%)� "��N��~�-���'�(�(�3 �3 �A��� 0��o�o�'�'�'�'�'�'�'�'�'�� �%�%��*�*�$�Q��4�+@�+@�+B�+B�B�B��-�-�/�/�/�* �-��)>��)>��*�)7�*�*�$�$�$�$�$�$�L�(��3�Q��Q�Q�Q�����|�$�$��)�)� 5�� 5�l�1�o� W�� W� W� W�PV� W� W�W�W�W�W�W�W�C��$�"7�7�7�=�t�4�W�=�#�l�1�o�&:�C�%@� � �DJ� � �����J�J�J�?�?�,�?�?�?�D�#*�>�������)5� ���$�������F��$�"7�7�7�=�t�4�W�=�#�T�#�d�F�*;�*;�%<�%<� � �@F� � ���� ��D�&� 1� 1�2�2�2�2�2��� � � �!�A�%�%�$�q�'�'�T�^�5V�*V�*V�#�a�'�N��H�H�H�H��G����� ����W3 �3 s2�BG0�$G0�(A&G0�G0�0 H-�:&H(�&H(�(H-� target_nodec��bK�dx}}d}|j}|dk�r |dz} |r4|�|���}|�d���d{V��d}nC|rA|j|��d{V��}|j�||jo|dtv��}d}|j|i|���d{V��S#ttf$r�ttf$rA|jj � |jd��|����d{V���t $r6|����d{V��t#jd���d{V���t&$rd} |xjdz c_|jr5|j|jzdkr"|����d{V��d|_n | |j_d}Yd} ~ njd} ~ wt.$r'} t1| j| j���}d}Yd} ~ n;d} ~ wt6$r+||jd z krt#jd ���d{V��YnwxYw|dk�� t9d ���) NFrrr��ASKING��?T�rwrxrvg�������?zTTL exhausted.)�RedisClusterRequestTTLr�rTr!rkr rlr)r/r6r3r;ryr_r�r�r1r��sleepr7rmrn�_moved_exceptionr.r'rwrxr<r2) r�rUrrY�asking�moved� redirect_addr�ttlrrSs rUrEzRedisCluster._execute_command�s��������� ��)���A�g�g� �1�H�C�; .�� "�"&�-�-�-�-�"H�"H�K�%�5�5�h�?�?�?�?�?�?�?�?�?�"�F�F��"�"6��!5�t�!<�<�<�<�<�<�<�D�"&�"4�"G�"G��d�5�R�$�q�'�]�:R�#�#�K�"�E�8�[�8�$�I�&�I�I�I�I�I�I�I�I�I��$�&9�:� � � ��#�\�2� � � � �"�0�4�4�[�5E�t�L�L�L��k�k�m�m�#�#�#�#�#�#�#��#� � � ��k�k�m�m�#�#�#�#�#�#�#��m�D�)�)�)�)�)�)�)�)�)��� � � ��)�)�Q�.�)�)��+�<��1�D�4K�K�q�P�P��+�+�-�-�'�'�'�'�'�'�'�01�D�-�-�:;�D�&�7������������� � � � -�1�6��� G� G� G� ������������ � .� .� .���4�q�8�8�8�!�-��-�-�-�-�-�-�-�-�-��� .����w�A�g�g�~�+�,�,�,s,�B B)�)B)H�AF1�1 H�>G � 5H�H� transaction� shard_hint�ClusterPipelinec�d�|rtd���|rtd���t|��S)z� Create & return a new :class:`~.ClusterPipeline` object. Cluster implementation of pipeline does not support transaction or shard_hint. :raises RedisClusterException: if transaction or shard_hint are truthy values z(shard_hint is deprecated in cluster modez)transaction is deprecated in cluster mode)r8rc)r�rarbs rU�pipelinezRedisCluster.pipeline<sB�� � T�'�(R�S�S� S� � U�'�(S�T�T� T��t�$�$�$rT皙�����?r��timeoutr[�blocking�blocking_timeout� lock_class� thread_localc �8�|�t}||||||||���S)aL Return a new Lock object using key ``name`` that mimics the behavior of threading.Lock. If specified, ``timeout`` indicates a maximum life for the lock. By default, it will remain locked until release() is called. ``sleep`` indicates the amount of time to sleep per loop iteration when the lock is in blocking mode and another client is currently holding the lock. ``blocking`` indicates whether calling ``acquire`` should block until the lock has been acquired or to fail immediately, causing ``acquire`` to return False and the lock not being acquired. Defaults to True. Note this value can be overridden by passing a ``blocking`` argument to ``acquire``. ``blocking_timeout`` indicates the maximum amount of time in seconds to spend trying to acquire the lock. A value of ``None`` indicates continue trying forever. ``blocking_timeout`` can be specified as a float or integer, both representing the number of seconds to wait. ``lock_class`` forces the specified lock implementation. Note that as of redis-py 3.0, the only lock class we implement is ``Lock`` (which is a Lua-based lock). So, it's unlikely you'll need this parameter, unless you have created your own custom lock class. ``thread_local`` indicates whether the lock token is placed in thread-local storage. By default, the token is placed in thread local storage so that a thread only sees its token, not a token set by another thread. Consider the following timeline: time: 0, thread-1 acquires `my-lock`, with a timeout of 5 seconds. thread-1 sets the token to "abc" time: 1, thread-2 blocks trying to acquire `my-lock` using the Lock instance. time: 5, thread-1 has not yet completed. redis expires the lock key. time: 5, thread-2 acquired `my-lock` now that it's available. thread-2 sets the token to "xyz" time: 6, thread-1 finishes its work and calls release(). if the token is *not* stored in thread local storage, then thread-1 would see the token value as "xyz" and would be able to successfully release the thread-2's lock. In some use cases it's necessary to disable thread local storage. For example, if you have code where one thread acquires a lock and passes that lock instance to a worker thread to release later. If thread local storage isn't disabled in this case, the worker thread won't see the token set by the thread that acquired the lock. Our assumption is that these cases aren't common and as such default to using thread local storage.N)rgr[rhrirkr)r�r�rgr[rhrirjrks rU�lockzRedisCluster.lockNs>��| � ��J��z� � ����-�%� � � � rT)rZrW�rZN�r�Nr�Nr�NrZN)rZrF)r�rFrZN�NNN�F)r�rrZN)NN)NrfTNNT)FrOrPrQ�__doc__� classmethodr4rra� __slots__rBr rr+r�boolr-�floatr �bytesr rKr]� TLSVersionrr r�r�r�r@r�r�r�rr�r��warnings�warnr��get_running_loopr�rr�r�r�r�r�r�r�r�rr>rrr rr rrrrr"r!r5r;rTr?rErerrmrSrTrUrWrW]s�������Q�Q�f��3��#��.�����[��@�I�(#� $�7;�&*�#(�"#�,-�/0�$��"�<@�"&�"&�%)�",�%4�_�%6�%6��'�!&�'(�26�!&�NR�*.�#'�:>��&*�%)�'�&*�#(�%)�48�%)�"#�PT�Ye2�e2��s�m�e2��C��H�o�e2�  ��]� 3�4� e2� $� e2�!�e2� �e2�'*�e2�*-�e2��e2� �#�s�(�O�e2��s�m�e2�&�&8�9�e2� �3�-�!e2�"�3�-�#e2�$�c�]�%e2�&�3�-�'e2�(�c�]�)e2�,�-e2�.�/e2�0�1e2�4 %�5e2�6!)���7e2�8�9e2�:#+�7�3��c�5�j�8I�3I�+J�"K�;e2�<!���=e2�>�� �?e2�@!��d�9�o�!6�7�Ae2�D�Ee2�F�s�m�Ge2�H�c�]�Ie2�J�Ke2�L�s�m�Me2�N!�Oe2�P�c�]�Qe2�R"�#�.�1�Se2�T�c�]�Ue2�V�3�-�We2�X ��%��S��/�):�E�#�s�(�O�)K� L�M�Ye2�Z �[e2�e2�e2�e2�N����& E� E� E� E����1G�g�V�V�V����W�V��'�'�'�'�����-�9�S�$��%>�?�-�-�-�-�2�L��]��,� � �� �� � � � � � � =�:� =�$� =� =� =� =�=�4� �.�=�=�=�=�D�t�M�2�D�D�D�D�D�d�=�1�D�D�D�D�L�L�L�L�/�/�/�/� /� /� /� /�#�"�#'� B�B��s�m�B��s�m�B��C�=� B� �-� � B�B�B�B�).�$�$��$�!%�$� �-� �$�$�$�$�82�:�2�#�2�2�2�2��W�����&�t�C��#��,>�'?�&�&�&�&��8�G�,�����#�#�#�#�4�S�4�<M�4�RV�4�4�4�4� DH�  �  �  ��  �#&�  �3;�C�=�  � �m� �  �  �  �  �D1�S�1��1��1�1�1�1�fQ�#�Q�$�Q�Q�Q�Q�����]�8K�����(R�:�R��R��R�R�R�R�hF-�(�F-�16�t�Z�7G�1H�F-�TW�F-� �F-�F-�F-�F-�RNR�%�%�#�C�=�%�=E�c�]�%� �%�%�%�%�*$(���,0�+/�!�H �H ��H ��%��H �� H � � H � #�5�/� H ��T�$�Z�(�H ��H � �H �H �H �H �H �H rTrWc��eZdZdZdZ d ded�dedeeefde ed ed e ed e d dfd �Z d efd�Z de d efd�ZdZejejfde de d dfd�Zd!d�Zd efd�Zdedede d e fd�Zde de d e fd�Zdedd efd�ZdS)"rFz� Create a new ClusterNode. Each ClusterNode manages multiple :class:`~redis.asyncio.connection.Connection` objects for the (host, port). ) r�_freer\rhrwr{r�rxro� server_typeNrs)r{r\rwrxr~r{r\rhrZc �N�|dkrtj|��}||d<||d<||_||_t ||��|_||_||_||_||_ |� di��|_ g|_ tj|j���|_dS)N� localhostrwrxro)�maxlen)�socket� gethostbynamerwrxr'r�r~r{r\rhr_ror� collections�dequer})r�rwrxr~r{r\rhs rUr�zClusterNode.__init__�s��� �;� � ��'��-�-�D�$(��&�!�$(��&�!��� ��� �!�$��-�-�� �&���.��� 0���!2���"3�"7�"7�8L�b�"Q�"Q���.0���(3�(9��AU�(V�(V�(V�� � � rTc �H�d|j�d|j�d|j�d|j�d� S)Nz[host=z, port=z, name=z, server_type=�])rwrxr�r~r�s rU�__repr__zClusterNode.__repr__�sV�� A�T�Y� A� A�t�y� A� A��I� A� A�-1�-=� A� A� A� rT�objc�L�t|t��o|j|jkSr�)r3rFr�)r�r�s rU�__eq__zClusterNode.__eq__�s ���#�{�+�+�E���D�I�0E�ErTzUnclosed ClusterNode objectr�r�c���|jD]b}|jrY||j�d|��t|��� ||jd�}|���|��n#t $rYnwxYwdS�cdS)Nr�r�r�)r� is_connectedr�r�r�r�)r�r�r�r�r�s rUr�zClusterNode.__del__�s��� �+� � �J��&� ����*�5�5�T�5�5��t�T�T�T�T��)-�$�:K�L�L�G��D�F�F�1�1�'�:�:�:�:��#�����D�������� � � s�'A� A$�#A$c��K�tjd�|jD��ddi��d{V��}td�|D��d��}|r|�dS)Nc3�bK�|]*}tj|�����V��+dSr��r�rD� disconnect)r)r�s rUrFz)ClusterNode.disconnect.<locals>.<genexpr>�sM��������#�J�$9�$9�$;�$;�<�<������rT�return_exceptionsTc3�DK�|]}t|t���|V��dSr�)r3rK)r)r�s rUrFz)ClusterNode.disconnect.<locals>.<genexpr>�s1����E�E�C�*�S�)�*D�*D�E�C�E�E�E�E�E�ErT)r�rIr�next)r�rR�excs rUr�zClusterNode.disconnect�s������N���"&�"3���� � #�  � � � � � � � ���E�E�3�E�E�E�t�L�L�� � ��I� � rTc�� |j���S#t$r\t|j��|jkr0|jdi|j��}|j�|��|cYSt���wxYw)NrS) r}�popleft� IndexErrorrrr{r\rhr�r6r�s rU�acquire_connectionzClusterNode.acquire_connection�s��� (��:�%�%�'�'� '��� (� (� (��4�$�%�%��(<�<�<�2�T�2�L�L�T�5K�L�L� ��!�(�(��4�4�4�!�!�!�!�%�'�'� '�  (���s��AB�2Br�rrYc��K� t|vr7|�d����d{V��}|�t��n|����d{V��}n'#t$rt|vr|tcYS�wxYwt|vr|�t��|�dd��||jvr|j||fi|��S|S)NT)�disable_decodingr/)rr�r_r9rro)r�r�rrY�responses rU�parse_responsezClusterNode.parse_response�s���� ��v�%�%�!+�!9�!9�4�!9�!P�!P�P�P�P�P�P�P��� � �<�(�(�(�(�!+�!9�!9�!;�!;�;�;�;�;�;�;����� � � ���'�'��n�-�-�-�-� � ���� �V� #� #� �J�J�~� &� &� &� � � �6�4� � � � �d�-� -� -�3�4�*�7�3�H�G�G��G�G� G��s�AA� B�Brc��"K�|���}|�|j|�d���d{V�� |j||dfi|���d{V�� |j�|��S#|j�|��wxYw)NFr)r��send_packed_command� pack_commandr�r}r�)r�rrYr�s rUrTzClusterNode.execute_commands������,�,�.�.� ��,�,�-D�Z�-D�d�-K�U�S�S�S�S�S�S�S�S�S� *�,��,�Z��a��K�K�F�K�K�K�K�K�K�K�K� K� �J� � �j� )� )� )� )��D�J� � �j� )� )� )� )���s �A2�2B�commands�PipelineCommandc��|K�|���}|�|�d�|D����d���d{V��d}|D]M} |j||jdfi|j���d{V��|_�.#t$r}||_d}Yd}~�Fd}~wwxYw|j� |��|S)Nc3�$K�|] }|jV�� dSr�)r�r)r�s rUrFz/ClusterNode.execute_pipeline.<locals>.<genexpr>*s$����$B�$B�#�S�X�$B�$B�$B�$B�$B�$BrTFrT) r�r�� pack_commandsr�rrY�resultrKr}r�)r�r�r�rRr�rSs rU�execute_pipelinezClusterNode.execute_pipeline$s0�����,�,�.�.� ��,�,� � $� $�$B�$B��$B�$B�$B� B� B�E� � � � � � � � � � ��� � �C� �#6�4�#6����� �$�$�/2�z�$�$�������� � ��� � � ��� ������������ ���� � ���*�%�%�%�� s�*B� B� B�Br�rn)rOrPrQrrrtrr4rr+r r rr�r�rur�r�ryrzr�r{r�r�r�r�rTrr�rSrTrUrFrF�s��������� �I�"&*� W� %�-7�W�W�W��W��C��H�o�W��c�]� W� � W��z�*�W�!�W� �W�W�W�W�8 �#� � � � � F�#�F�$�F�F�F�F�1�L��]��,������� � ���� � � � � (�J� (� (� (� (��$��/2��>A�� �����4 *�3� *�#� *�#� *� *� *� *��t�4E�/F��4������rTc��eZdZdZ ddeddedeeefde e e ee fge ee ffddf d �Z dd e ed e e d e ede dfd �Z d deedfdeedfdeddfd�Zd!d�Z d de deddfd�Zdededfd�Zd!d�Zd"deddfd�Zd ed e de ee ffd�ZdS)#r�) r\rhr�r��read_load_balancerrzrryr�NryrFrzrhr�rZc��d�|D��|_||_||_||_d|_i|_i|_t��|_d|_ dS)Nc��i|] }|j|�� SrSr@rAs rU� <dictcomp>z)NodesManager.__init__.<locals>.<dictcomp>Rs��H�H�H�$�d�i��H�H�HrT) ryrzrhr�r�r�rr%r�r\)r�ryrzrhr�s rUr�zNodesManager.__init__Kse��I�H�-�H�H�H���%:��"�!2���*���+/���57���;=���".�.�.���,0����rTrwrxr�c���|rE|rC|dkrtj|��}|j�t ||�����S|r|j�|��St d���)Nr�rYzEget_node requires one of the following: 1. node name 2. host and port)r�r�r�r�r'r4r�s rUr�zNodesManager.get_node]s��� � �D� ��{�"�"��+�D�1�1���#�'�'� �4�d�(K�(K�(K�L�L� L� � ��#�'�'� �2�2� 2��#��� rTF�old�new� remove_oldc��|rat|�����D]?}||vr9tj|�|�������}�@|���D]E\}}||vr7|||ur�tj||�����}|||<�FdSr�)r�r/r�rDr_r��items)r�r�r�r�r��taskr�s rU� set_nodeszNodesManager.set_nodesqs��� � K��S�X�X�Z�Z�(�(� K� K���s�?�?�"�.�s�w�w�t�}�}�/G�/G�/I�/I�J�J�D���)�)�+�+� � �J�D�$��s�{�{��t�9��$�$���*�3�t�9�+?�+?�+A�+A�B�B���C��I�I�  � rTc��|j}|�|j|j���}|r|jt kr t |_nEt |j|jt fi|j��}|�|j |j |i��||j |j vr�|j |j d}t|_|j |j �|��|j |j �|��||j |j d<|j|kr||_n|g|j |j <d|_dS)NrYr)r\r�rwrxr~r!rFrhr�r�r�r�slot_idr"r��remover�)r�rS�redirected_node� old_primarys rU�_update_moved_slotsz NodesManager._update_moved_slots�sP�� � !���-�-�Q�V�!�&�-�A�A�� � V��*�g�5�5�.5��+��*��������+/�+A���O� �N�N�4�+�o�.B�O�-T� U� U� U� �d�.�q�y�9� 9� 9��*�1�9�5�a�8�K�'.�K� #� � �Q�Y� '� .� .�{� ;� ;� ;� � �Q�Y� '� .� .�� ?� ?� ?�-<�D� �Q�Y� '�� *�� �K�/�/�$3��!�� ,;�*;�D� �Q�Y� '� $����rTrrlc��|jr|��� |r^|j|dj}|j�|t |j|����}|j||S|j|dS#ttf$rtd|�d|j �d����wxYw)Nrr�z5" not covered by the cluster. "require_full_coverage=�") r\r�rr�r��get_server_indexrr�r8r:rz)r�rrl� primary_namers rUr zNodesManager.get_node_from_slot�s��� � � '� � $� $� &� &� &� �!� 8�#�/��5�a�8�=� ��2�C�C� �#�d�&6�t�&<�"=�"=�����'��-�h�7�7��#�D�)�!�,� ,���I�&� � � �%�H��H�H�*.�*D�H�H�H��� � ���s�AB�=B�-B=r~c�N���fd�|j���D��S)Nc�*��g|]}|j�k� |��SrS)r~)r)r�r~s �rUrBz9NodesManager.get_nodes_by_server_type.<locals>.<listcomp>�s1��� � � ����;�.�.� �.�.�.rT)r�r�)r�r~s `rUr�z%NodesManager.get_nodes_by_server_type�s=��� � � � ��(�/�/�1�1� � � � rTc ��8K�|j���i}i}g}d}d}d}|j���D�]} |�d���d{V��}n#t $rt d���wxYwd}n#t$r } | }Yd} ~ �Rd} ~ wwxYwt|��dkrB|ddds.t|j��dkr|j |ddd<|D�]:} tdt| ����D]} d�| | D��| | <�| d} | d} | d kr|j } t| d��}|� | |��\} }g}|� t| |����}|st| |t fi|j��}|||j<|�|��| d d�}|D]�}|d} |d}|� | |��\} }|� t| |����}|st| |t(fi|j��}|||j<|�|����tt| d��t| d��dz��D]�} | |vr||| <� || d}|j|jkr_|�|j�d |j�d | ����t|��d kr%t dd�|�����������<d}tt,��D] } | |vrd}n� |rn��|s t dt/|������|�|s/|jr(t dt|���dt,�d����||_|�|j|d���|�|j|jd���|�t ��d|_d|_dS)NFr�z(Cluster mode is not enabled on this nodeTrrrvc�,�g|]}t|����SrS)rD)r)�vals rUrBz+NodesManager.initialize.<locals>.<listcomp>�s ��D�D�D�S�|�C�0�0�D�D�DrT�rrz vs z on slot: rqz6startup_nodes could not agree on a valid slots cache: z, zORedis Cluster cannot be connected. Please provide at least one reachable node: z9All slots are not covered after query all startup_nodes. z of z covered...)r�)r��resetryr�rTr9r8rKrrwrGr+�remap_host_portr�r'rFr!rhr�r�r"�joinr+r4rzrr�r�r�r�r\)r��tmp_nodes_cache� tmp_slots� disagreements�startup_nodes_reachable� fully_covered� exception� startup_node� cluster_slotsrSr�i� primary_noderwrx�nodes_for_slotrU� replica_nodes� replica_node�target_replica_node�tmp_slots rUr�zNodesManager.initialize�sO���� ��%�%�'�'�'�46��46� �� �"'��� �� � �.�5�5�7�7�[ �[ �L� ��*6�*F�*F��*W�*W�$W�$W�$W�$W�$W�$W�M�M��$����/�B��������+/�'�'��� � � �� ����������  �����M�"�"�a�'�'�%�a�(��+�A�.�(���*�+�+�q�0�0�)5�):� �a� ��#�A�&�%�4 "�4 "���q�#�d�)�)�,�,�E�E�A�D�D�D��G�D�D�D�D��G�G�#�A�w� �#�A����2�:�:�'�,�D��<��?�+�+��!�1�1�$��=�=� ��d�!#��-�1�1�-��d�2K�2K�L�L� �"��"-��d�G�#�#�/3�/E�#�#�K�5@�� � 0�1��%�%�k�2�2�2� $�Q�R�R�� �$1� ?� ?�L�'��?�D�'��?�D�!%�!5�!5�d�D�!A�!A�J�D�$�*9�*=�*=�m�D�RV�>W�>W�*X�*X�'�.��.9� �$��/�/�37�3I�/�/�+�AT�O�$7�$<�=�"�)�)�*=�>�>�>�>��s�4��7�|�|�S��a��\�\�A�-=�>�>�"�"�A�� �)�)�'5� �!� � �$-�Q�<��?��#�=�K�,<�<�<�)�0�0�#+�=� U� U�k�6F� U� U�RS� U� U���� #�=�1�1�A�5�5�&;�%O�48�I�I�m�4L�4L�%O�%O�'"�'"�!"��"�&!�M��3�4�4� � ���I�%�%�$)�M��E�&�� ��� �'� �'�8�'*�9�~�~�8�8���� � � ��!;� �(���y�>�>���'?������ �%��� ���t�'��T��J�J�J� ���t�)�4�+;���M�M�M�!�9�9�'�B�B�1�E��� $����s*�A"�!B�"A<�<B� B� B�Br��attrc��K�d|_tjd�t||�����D����d{V��dS)Nc3�bK�|]*}tj|�����V��+dSr�r�rAs rUrFz&NodesManager.aclose.<locals>.<genexpr>HsK��������#�D�O�O�$5�$5�6�6������rT)r�r�rI�getattrr�)r�r�s rUr�zNodesManager.acloseEsw���� ����n���#�D�$�/�/�6�6�8�8���� � � � � � � � � � rTc�F�|jr|�||f��S||fS)z� Remap the host and port returned from the cluster to a different internal value. Useful if the client is not connecting directly to the cluster. r�)r�rwrxs rUr�zNodesManager.remap_host_portNs1�� � � 4��%�%�t�T�l�3�3� 3��T�z�rTr�rprqrn)r�)rOrPrQrtrrurr4rr rr r+r�r�r�r�r r�r�r�r�rSrTrUr�r�>s0������ �I�"QU� 1�1��M�*�1� $�1� ��S��>� 1�  ��%��S��/�):�E�#�s�(�O�)K� L�M� 1� � 1�1�1�1�(#�"�#'� ���s�m���s�m���C�=� � �-� � ����0!� �� �#�}�$� %���#�}�$� %��� � � ����$$%�$%�$%�$%�N5:�����-1�� �����* �C� �D��<O� � � � �~%�~%�~%�~%�@ � �� �� � � � ��C��s��u�S�#�X�������rTr�c �:�eZdZdZdZdeddfd�Zd"d�Zd"d�Zd#d �Z de e ddffd �Z d"d�Z d#d�Zdefd�Zdefd�Zdeeefde ddfd�Z d$dededee fd�Z d$dddeddededee f d�Zdededdfd�Zd eeefddfd!�ZdS)%rca� Create a new ClusterPipeline object. Usage:: result = await ( rc.pipeline() .set("A", 1) .get("A") .hset("K", "F", "V") .hgetall("K") .mset_nonatomic({"A": 2, "B": 3}) .get("A") .get("B") .delete("A", "B", "K") .execute() ) # result = [True, "1", 1, {"F": "V"}, True, True, "2", "3", 1, 1, 1] Note: For commands `DELETE`, `EXISTS`, `TOUCH`, `UNLINK`, `mset_nonatomic`, which are split across multiple nodes, you'll get multiple results for them in the array. Retryable errors: - :class:`~.ClusterDownError` - :class:`~.ConnectionError` - :class:`~.TimeoutError` Redirection errors: - :class:`~.TryAgainError` - :class:`~.MovedError` - :class:`~.AskError` :param client: | Existing :class:`~.RedisCluster` client )�_command_stack�_clientr�rZNc�"�||_g|_dSr�)r�r�)r�r�s rUr�zClusterPipeline.__init__�s���� �79����rTc��nK�|jjr|j����d{V��g|_|Sr�)r�rbr�r�r�s rUr�zClusterPipeline.initialize�sF���� �<� #� ,��,�)�)�+�+� +� +� +� +� +� +� +� ���� rTc��:K�|����d{V��Sr�r�r�s rUr�zClusterPipeline.__aenter__�r�rTr�r�r�c��K�g|_dSr��r�r�s rUr�zClusterPipeline.__aexit__�s���� ����rTc�N�|������Sr�r�r�s rUr�zClusterPipeline.__await__�r�rTc��g|_|Sr�r�r�s rU� __enter__zClusterPipeline.__enter__�s�� ���� rTc��g|_dSr�r�r�s rU�__exit__zClusterPipeline.__exit__�s�� ����rTc��dS)z?Pipeline instances should always evaluate to True on Python 3+TrSr�s rU�__bool__zClusterPipeline.__bool__�s���trTc�*�t|j��Sr�)rr�r�s rU�__len__zClusterPipeline.__len__�s���4�&�'�'�'rTrrYc�z�|j�tt|j��g|�Ri|����|S)ad Append a raw command to the pipeline. :param args: | Raw command args :param kwargs: - target_nodes: :attr:`NODE_FLAGS` or :class:`~.ClusterNode` or List[:class:`~.ClusterNode`] or Dict[Any, :class:`~.ClusterNode`] - Rest of the kwargs are passed to the Redis connection )r�r�r�r)r�rrYs rUrTzClusterPipeline.execute_command�sL�� ��"�"� �C�� 3�4�4� F�t� F� F� F�v� F� F� � � �� rTT�raise_on_error�allow_redirectionsc��K�|jsgS t|jj��D]�}|jjr|j����d{V�� |�|j|j||����d{V��cg|_S#t$rb}t|��|j j vr<|}|j� ���d{V��tj d���d{V��n�Yd}~��d}~wwxYw|�#g|_wxYw)a  Execute the pipeline. It will retry the commands as specified by :attr:`cluster_error_retry_attempts` & then raise an exception. :param raise_on_error: | Raise the first error if there are any errors :param allow_redirections: | Whether to retry each failed command individually in case of redirection errors :raises RedisClusterException: if target_nodes is not provided & the command can't be mapped to a slot N)r�r�rX)r�rGr�rdrbr��_executer�r9r�rLr�r�r[)r�r�r�rQrSr�s rU�executezClusterPipeline.execute�s�����$�"� ��I� %��4�<�D�E�E� � ���<�+�4��,�1�1�3�3�3�3�3�3�3�3�3��!%���� ��+�'5�+=� "/�"�"���������&#%�D� � ��%�����A�w�w�$�.�"C�C�C�$%� �"�l�1�1�3�3�3�3�3�3�3�3�3�%�m�D�1�1�1�1�1�1�1�1�1�1��2�1�1�1�1����� �����O��"$�D� � $� $� $� $s7�AC7�(B�<C7� C2�AC-�(C7�-C2�2C7�7 DrW�stackr�c��TK�d�|D��}i}|D]�}|j�dd��}|r+|�|��s|�|��} n2|j|jd|i��d{V��} | st d|j�d����t| ��dkrt d|j�����| d} | j|vr | gf|| j<|| jd� |����tj d �|� ��D����d{V��} t| ���ra|rn|D]k}t|jt t"t$f��rB |j|ji|j���d{V��|_�M#t($r} | |_Yd} ~ �cd} ~ wwxYw�l|r�|D]}}|j} t| t(��r_d �t-t.|j����}d |jdz�d |�d | j��}|f| jdd�z| _| ��~|�|���j��}|�A|dD]8}t7|j��|jjvr|���n�9d�|D��S)Nc�T�g|]%}|jrt|jt���#|��&SrS)r�r3rKr�s rUrBz,ClusterPipeline._execute.<locals>.<listcomp>�sC�� � � ��� � �6@���Y�6W�6W� � � � � rTr1rr=r>rzToo many targets for command rc3�|K�|]7}tj|d�|d����V��8dS)rrN)r�rDr�rAs rUrFz+ClusterPipeline._execute.<locals>.<genexpr>sW��������#�D��G�$<�$<�T�!�W�$E�$E�F�F������rTr�z Command # � (z) of pipeline caused error: c��g|] }|j�� SrS)r�r�s rUrBz,ClusterPipeline._execute.<locals>.<listcomp>0s��,�,�,�s�� �,�,�,rT)rYr_r5r;r"rr8rr�r�r�rIr��anyr3r�r<r7r.rTrKr��maprC�positionr�r�r9r�rLrH)r�r�r�r�r��todor:r�rOr1r��errorsrSr�r�msgr�s rUr�zClusterPipeline._execute�s����� � � � � � ����� ,� ,�C� �Z�^�^�N�D�A�A�N�� �f�&:�&:�>�&J�&J� �%�9�9�.�I�I� � �%<�V�%<��X�&�)7�&�&� � � � � � � �$��/�Q�C�H�Q�Q�Q�����<� � �1�$�$�+�,V�C�H�,V�,V�W�W�W���?�D��y��%�%�$(�"�:��d�i� � �$�)� �Q� � &� &�s� +� +� +� +��~���!�L�L�N�N���� � � � � � � �� �v�;�;�# �!� +��+�+�C�!�#�*�}�j�(�.S�T�T�+�+�/E�v�/E�!$��0�-0�Z�0�0�*�*�*�*�*�*�C�J�J�� )�+�+�+�)*�C�J�J�J�J�J�J�����+���� +�� %�� %� %�C� �Z�F�!�&�)�4�4�%�"%�(�(�3�x���+B�+B�"C�"C��;����)9�;�;�W�;�;�-3�[�;�;��(+�f�v�{�1�2�2��&>�� �$� �%�!�9�9�V�%<�%<�%>�%>�%C�D�D�L��'� (��?���C��C�J�'�'�4�>�+L�L�L��3�3�5�5�5���M�-�,�e�,�,�,�,s�+"F� F)�F$�$F)rr/c��|j�|�����D]}|j|g|�R��|Sr�)r��_partition_keys_by_slotr�rT)r�rr/� slot_keyss rU�_split_command_across_slotsz+ClusterPipeline._split_command_across_slots2sR����=�=�d�C�C�J�J�L�L� 6� 6�I� �D� �� 5�9� 5� 5� 5� 5� 5�� rT�mappingc�<�|jj}i}|���D]S}t|�|d����}|�|g���|���T|���D]}|jdg|�R��|S)Nr�MSET) r�rir�r,r � setdefault�extendr�rT)r�rri� slots_pairs�pairr�pairss rU�mset_nonatomiczClusterPipeline.mset_nonatomic:s����,�&��� ��M�M�O�O� :� :�D��G�N�N�4��7�3�3�4�4�D� � "� "�4�� ,� ,� 3� 3�D� 9� 9� 9� 9� �'�'�)�)� 1� 1�E� �D� �� 0�%� 0� 0� 0� 0� 0�� rT)rZrcro)TT)rOrPrQrrrtrWr�r�r�r�rrr�r�r�rur�r+r�rr?r>rTrr�r�r4rr r=r rSrTrUrcrcYs=������"�"�H.�I�:�|�:��:�:�:�:� ���� '�'�'�'�!�!�!�!�-�9�S�$�0A�%A�B�-�-�-�-�����!�!�!�!��$�����(��(�(�(�(���4��+�,��8;�� �����(GK�.%�.%�"�.%�?C�.%� �c��.%�.%�.%�.%�h $�#'� K-�K-��K-��%�&�K-�� K-� !� K-� �c�� K-�K-�K-�K-�Z���#'�� ����� ��w� �2�3� � � � � � � � rTrcr�rQr c�2�eZdZdedededdfd�Zdefd�ZdS)r�r�rrYrZNc�>�||_||_||_d|_dSr�)rrYr�r�)r�r�rrYs rUr�zPipelineCommand.__init__Ss"���� ��� � �� �-1�� � � rTc�8�d|j�d|j�d|j�d�S)N�[z] r��))r�rrYr�s rUr�zPipelineCommand.__repr__Ys)��?�4�=�?�?�D�I�?�?���?�?�?�?rT)rOrPrQr+rr�r4r�rSrTrUr�r�Rsf������2��2�S�2�C�2�D�2�2�2�2� @�#�@�@�@�@�@�@rTr�)cr�r�r�r�r]ry�typingrrrrrrr r r r r r�redis._parsersrr�redis._parsers.helpersrrr�redis.asyncio.clientr�redis.asyncio.connectionrrrr�redis.asyncio.lockr�redis.asyncio.retryr� redis.backoffr� redis.clientrrr� redis.clusterr r!r"r#r$r%r&r'r(�redis.commandsr)r*� redis.crcr+r,�redis.credentialsr-�redis.exceptionsr.r/r0r1r2r3r4r5r6r7r8r9r:r;r<� redis.typingr=r>r?� redis.utilsr@rArBrCrDr4rErHrWrFr�rcr�replace�lower�setattrr�rSrTrU�<module>r%s0���������� � � � � � � � � � � � ����� � � � � � � � � � � � � � � � � � � � � � � � � � � � �8�7�7�7�7�7�7�7����������� 3�2�2�2�2�2�X�X�X�X�X�X�X�X�X�X�X�X�#�#�#�#�#�#�%�%�%�%�%�%�)�)�)�)�)�)�D�D�D�D�D�D�D�D�D�D� � � � � � � � � � � � � � � � � � � � � � �D�C�C�C�C�C�C�C�8�8�8�8�8�8�8�8�0�0�0�0�0�0�����������������������������������"3�2�2�2�2�2�2�2�2�2����������������w��C���]�(;�T�#�}�BT�=U��� � � � � � �M� � � �y  �y  �y  �y  �y  �=�"6�8Q�y  �y  �y  �xb�b�b�b�b�b�b�b�JX�X�X�X�X�X�X�X�vn�n�n�n�n�m�%9�;T�n�n�n�b)�G�G�G��o�o�c�3�'�'�-�-�/�/�G��"�"�"�� �G�O�W�&<�&<�W�&E�&E�F�F�F�F�@�@�@�@�@�@�@�@�@�@rT
Memory