403Webshell
Server IP : 127.0.1.1  /  Your IP : 216.73.216.17
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux dalsi.io 6.8.0-117-generic #117-Ubuntu SMP PREEMPT_DYNAMIC Tue May 5 19:26:24 UTC 2026 x86_64
User : www-data ( 33)
PHP Version : 8.3.6
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/redis/asyncio/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/redis/asyncio/__pycache__/sentinel.cpython-312.pyc
�

���bG4���ddlZddlZddlZddlmZmZmZmZmZm	Z	ddl
mZddlm
Z
mZmZmZddlmZddlmZmZmZmZddlmZGd�d	e�ZGd
�de�ZGd�d
e
�ZGd�dee�ZGd�de�ZGd�de�Zy)�N)�
AsyncIterator�Iterable�Mapping�Sequence�Tuple�Type)�Redis)�
Connection�ConnectionPool�
EncodableT�
SSLConnection)�AsyncSentinelCommands)�ConnectionError�
ReadOnlyError�
ResponseError�TimeoutError)�str_if_bytesc��eZdZy)�MasterNotFoundErrorN��__name__�
__module__�__qualname__���8/usr/lib/python3/dist-packages/redis/asyncio/sentinel.pyrr���rrc��eZdZy)�SlaveNotFoundErrorNrrrrrrrrrc�F��eZdZ�fd�Zd�Z�fd�Zd�Zddef�fd�
Z�xZ	S)�SentinelManagedConnectionc�P��|jd�|_t�|�di|��y)N�connection_poolr)�popr#�super�__init__)�self�kwargs�	__class__s  �rr&z"SentinelManagedConnection.__init__s%���%�z�z�*;�<���
���"�6�"rc���|j}|jj�d|j��}|jr!d|j�d|j
��}||z
}|dzS)N�	<service=z,host=z,port=�>)r#r)r�service_name�host�port)r'�pool�s�	host_infos    r�__repr__z"SentinelManagedConnection.__repr__sb���#�#���~�~�&�&�'�y��1B�1B�0C�D���9�9� �����6�$�)�)��=�I�
��N�A��3�w�rc��"�K�|\|_|_t�|�
��d{���|jj
rI|j
d��d{���t|j��d{����dk7rtd��yy7�d7�77��w)N�PING�PONGzPING failed)
r.r/r%�connectr#�check_connection�send_commandr�
read_responser)r'�addressr)s  �r�
connect_toz$SentinelManagedConnection.connect_to's������&���	�4�9��g�o�������0�0��#�#�F�+�+�+��$�"4�"4�"6�6�7�6�A�%�m�4�4�B�1�	 ��+��6�s3�!B�B	�.B�B�B�0B
�1B�B�
Bc��~K�|jry|jjr:|j|jj	��d{�����d{���y|jj�23d{���}	|j|��d{���cS7�P7�F7�$7�#t$rY�8wxYw6t��w�N)�_readerr#�	is_masterr<�get_master_address�
rotate_slavesrr)r'�slaves  rr7z!SentinelManagedConnection.connect/s������<�<�����)�)��/�/��(<�(<�(O�(O�(Q�"Q�R�R�R�#�3�3�A�A�C�
�
�e��!%����!7�7�7�	#R��R��
��7��&����� D�
%�$�sx�AB=�B�B=�B!�B=�:B6�>B#�?B6�B=�B'�B%�B'�B=�!B=�#B6�%B'�'	B3�0B=�2B3�3
B=�disable_decodingc����K�	t�|�|���d{���S7�#t$r<|jjr$|j��d{���7t
d���wxYw�w)N)rDz"The previous master is now a slave)r%r:rr#r@�
disconnectr)r'rDr)s  �rr:z'SentinelManagedConnection.read_response<sd�����	���.�@P�.�Q�Q�Q�Q���		��#�#�-�-��o�o�'�'�'�%�&J�K�K��		�s1�A'����A'��2A$�A�A$�$A')F)
rrrr&r3r<r7�boolr:�
__classcell__�r)s@rr!r!s(���#��5�%��D��rr!c��eZdZy)�SentinelManagedSSLConnectionNrrrrrKrKKrrrKc�T��eZdZdZ�fd�Zd�Z�fd�Zdef�fd�Zd�Z	de
fd	�Z�xZS)
�SentinelConnectionPoolz�
    Sentinel backed connection pool.

    If ``check_connection`` flag is set to True, SentinelManagedConnection
    sends a PING command right after establishing the connection.
    c�^��|jd|jdd�rtnt�|d<|jdd�|_|jdd�|_t
�|�di|��tj|�|jd<||_||_d|_
d|_y)	N�connection_class�sslFr@Tr8r#r)�getr$rKr!r@r8r%r&�weakref�proxy�connection_kwargsr-�sentinel_manager�master_address�slave_rr_counter)r'r-rUr(r)s    �rr&zSentinelConnectionPool.__init__Ws����%+�Z�Z���z�z�%��'�
)�*�	&
��!�"� ���K��6��� &�
�
�+=�u� E���
���"�6�"�4;�M�M�$�4G����0�1�(��� 0���"��� $��rc�x�|jj�d|j�d|jxrdxsd�d�S)Nr+�(�masterrCz)>)r)rr-r@)r's rr3zSentinelConnectionPool.__repr__gsC���~�~�&�&�'���)�)�*�!�D�N�N�,G�x�,R�7�+S�SU�
W�	
rc�>��t�|��d|_d|_yr>)r%�resetrVrW)r'r)s �rr\zSentinelConnectionPool.resetms���
��
��"��� $��r�
connectionc���|jxs3|jxr%|j|j|jfk(}|xrt�|�|�Sr>)r@rVr.r/r%�owns_connection)r'r]�checkr)s   �rr_z&SentinelConnectionPool.owns_connectionrsR����N�N�"�
��N�N�X�t�2�2�z���
���6X�X�	��<���0��<�<rc���K�|jj|j��d{���}|jr0|j|k7r!||_|jd���d{���|S7�B7��w)NF)�inuse_connections)rU�discover_masterr-r@rVrF)r'rVs  rrAz)SentinelConnectionPool.get_master_addressxsj����#�4�4�D�D�T�EV�EV�W�W���>�>��"�"�n�4�&4��#��o�o��o�>�>�>���X��?�s!�)A2�A.�;A2�'A0�(A2�0A2�returnc�K�|jj|j��d{���}|r�|j�'t	j
dt
|�dz
�|_tt
|��D]6}|jdzt
|�z|_||j}|����8	|j��d{������td|j����7��7�!#t$rY�'wxYw�w)zRound-robin slave balancerNr�zNo slave found for )rU�discover_slavesr-rW�random�randint�len�rangerArr)r'�slaves�_rCs    rrBz$SentinelConnectionPool.rotate_slaves�s������,�,�<�<�T�=N�=N�O�O����$�$�,�(.���q�#�f�+��/�(J��%��3�v�;�'�
��)-�)>�)>��)B�c�&�k�(Q��%��t�4�4�5����
�
	��/�/�1�1�1�!�#6�t�7H�7H�6K�!L�M�M�P��2��"�	��	�sF�)C9�C&�BC9�3C*�C(�C*�C9�(C*�*	C6�3C9�5C6�6C9)
rrr�__doc__r&r3r\r
r_rArrBrHrIs@rrMrMOs6����%� 
�%�
=�*�=��N�]�NrrMc���eZdZdZ		dd�Zd�Zd�Zdedede	fd	�Z
defd
�Zdee
deeeeffd�Zdedeeeeffd
�Zeefdedeedeefd�Zeefdedeedeefd�Zy)�Sentinela~
    Redis Sentinel cluster client

    >>> from redis.sentinel import Sentinel
    >>> sentinel = Sentinel([('localhost', 26379)], socket_timeout=0.1)
    >>> master = sentinel.master_for('mymaster', socket_timeout=0.1)
    >>> await master.set('foo', 'bar')
    >>> slave = sentinel.slave_for('mymaster', socket_timeout=0.1)
    >>> await slave.get('foo')
    b'bar'

    ``sentinels`` is a list of sentinel nodes. Each node is represented by
    a pair (hostname, port).

    ``min_other_sentinels`` defined a minimum number of peers for a sentinel.
    When querying a sentinel, if it doesn't meet this threshold, responses
    from that sentinel won't be considered valid.

    ``sentinel_kwargs`` is a dictionary of connection arguments used when
    connecting to sentinel instances. Any argument that can be passed to
    a normal Redis connection can be specified here. If ``sentinel_kwargs`` is
    not specified, any socket_timeout and socket_keepalive options specified
    in ``connection_kwargs`` will be used.

    ``connection_kwargs`` are keyword arguments that will be used when
    establishing a connection to a Redis server.
    Nc
��|�5|j�D��cic]\}}|jd�s�||��}}}||_|D��cgc]\}}td||d�|j����c}}|_||_||_ycc}}wcc}}w)N�socket_)r.r/r)�items�
startswith�sentinel_kwargsr	�	sentinels�min_other_sentinelsrT)	r'rvrwrurT�k�v�hostnamer/s	         rr&zSentinel.__init__�s����"�!2�!8�!8�!:����A�a�l�l�9�>U��1���O�� /���#,�
���$�
�C�x�d�C�d�.B�.B�C�
���$7�� �!2������

s�A>�A>�"Bc
��K�t|jdd��}d|j�vr|jd�|rW|jD�cgc]'}tj|j|i|�����)}}tj|��d{���ytj|j�j|i|���d{���ycc}w7�B7��w)z�
        Execute Sentinel command in sentinel nodes.
        once - If set to True, then execute the resulting command on a single
               node at random, rather than across the entire sentinel cluster.
        �onceFNT)rGrQ�keysr$rv�asyncio�Task�execute_command�gatherrh�choice)r'�argsr(r|�sentinel�taskss      rr�zSentinel.execute_command�s������F�J�J�v�u�-�.���V�[�[�]�"��J�J�v���!%��������5�X�5�5�t�F�v�F�G��E���.�.�%�(�(�(��@�&�-�-����/�?�?��P��P�P�P����
)��P�s0�AC�,C�=C�C�7C�C�
C�Cc��g}|jD]F}|j|jjd�d|jjd����H|jj
�ddj
|��d�S)Nr.�:r/z<sentinels=[�,z]>)rv�appendr#rTr)r�join)r'�sentinel_addressesr�s   rr3zSentinel.__repr__�s��������	�H��%�%��+�+�=�=�f�E�F�a��+�+�=�=�f�E�F�H�
�	�
�.�.�)�)�*�,�s�x�x�@R�7S�6T�TV�W�Wr�stater-rdc�J�|dr
|ds|dry|d|jkryy)Nr@�is_sdown�is_odownFznum-other-sentinelsT)rw)r'r�r-s   r�check_master_statezSentinel.check_master_state�s5���[�!�U�:�%6�%�
�:K���&�'�$�*B�*B�B��rc��|K�t|j�D]|\}}	|j��d{���}|j|�}|s�3|j
||�s�F||jdc|jd<|j|<|d|dfcStd|����7�r#ttf$rY��wxYw�w)z�
        Asks sentinel servers for the Redis master's address corresponding
        to the service labeled ``service_name``.

        Returns a pair (address, port) or raises MasterNotFoundError if no
        master is found.
        Nr�ipr/zNo master found for )�	enumeraterv�sentinel_mastersrrrQr�r)r'r-�sentinel_nor��mastersr�s      rrczSentinel.discover_master�s�����&/�t�~�~�%>�	2�!�K��
� (� 9� 9� ;�;���K�K��-�E���0�0���E���N�N�1�%�?����q�!�4�>�>�+�#>��T�{�E�&�M�1�1�	2�"�$8��8H�"I�J�J�<��#�\�2�
��
�sD�B<�B'�B%�B'�B<�B<�AB<�%B'�'B9�6B<�8B9�9B<rlc�`�g}|D]&}|ds|dr�|j|d|df��(|S)z1Remove slaves that are in an ODOWN or SDOWN stater�r�r�r/)r�)r'rl�slaves_aliverCs    r�
filter_slaveszSentinel.filter_slavessM�����	>�E��Z� �E�*�$5������t��e�F�m� <�=�	>��rc���K�|jD]3}	|j|��d{���}|j|�}|s�1|cSgS7�#tttf$rY�PwxYw�w)z;Returns a list of alive slaves for service ``service_name``N)rv�sentinel_slavesrrrr�)r'r-r�rls    rrgzSentinel.discover_slavessr�������	�H�
�'�7�7��E�E���'�'��/�F���
�	��	�
F��#�]�L�A�
��
�s=�A#�A	�A�A	�A#�A#�A	�	A �A#�A � A#�redis_class�connection_pool_classc�z�d|d<t|j�}|j|�||||fi|����S)a�
        Returns a redis client instance for the ``service_name`` master.

        A :py:class:`~redis.sentinel.SentinelConnectionPool` class is
        used to retrieve the master's address before establishing a new
        connection.

        NOTE: If the master's address has changed, any cached connections to
        the old master are closed.

        By default clients will be a :py:class:`~redis.Redis` instance.
        Specify a different class to the ``redis_class`` argument if you
        desire something different.

        The ``connection_pool_class`` specifies the connection pool to
        use.  The :py:class:`~redis.sentinel.SentinelConnectionPool`
        will be used by default.

        All other keyword arguments are merged with any connection_kwargs
        passed to this class and passed to the connection pool as keyword
        arguments to be used to initialize Redis connections.
        Tr@�r#��dictrT�update�r'r-r�r�r(rTs      r�
master_forzSentinel.master_forsO��:#��{�� ��!7�!7�8��� � ��(��1��d��&7��
�	
rc�z�d|d<t|j�}|j|�||||fi|����S)a�
        Returns redis client instance for the ``service_name`` slave(s).

        A SentinelConnectionPool class is used to retrieve the slave's
        address before establishing a new connection.

        By default clients will be a :py:class:`~redis.Redis` instance.
        Specify a different class to the ``redis_class`` argument if you
        desire something different.

        The ``connection_pool_class`` specifies the connection pool to use.
        The SentinelConnectionPool will be used by default.

        All other keyword arguments are merged with any connection_kwargs
        passed to this class and passed to the connection pool as keyword
        arguments to be used to initialize Redis connections.
        Fr@r�r�r�s      r�	slave_forzSentinel.slave_forBsO��0$��{�� ��!7�!7�8��� � ��(��1��d��&7��
�	
r)rN)rrrrnr&r�r3r��strrGr�rcrrrrrr�rgr	rMrr�r�rrrrprp�s����>��	3�,�(X����C��D��K�#�K�.	��w�'�	�	�%�
�J�.�/�	0�	����	�%�
�J�.�/�	0��"$)�>T�	$
��$
��%�[�$
� $�$:�;�	$
�R$)�>T�	
��
��%�[�
� $�$:�;�	
rrp) r~rhrR�typingrrrrrr�redis.asyncio.clientr	�redis.asyncio.connectionr
rrr
�redis.commandsr�redis.exceptionsrrrr�redis.utilsrrrr!rKrMrprrr�<module>r�s����
��J�J�&���1�X�X�$�	�/�	�	��	�.�
�.�b	�#<�m�	�BN�^�BN�JM
�$�M
r

Youez - 2016 - github.com/yon3zu
LinuXploit