� J�g�����ddlZddlZddlZddlZddlZddlZddlmZmZm Z m Z m Z m Z m Z mZmZmZmZmZmZmZmZmZmZmZmZddlmZmZmZmZddlm Z m!Z!m"Z"m#Z#ddl$m%Z%ddl&m'Z'ddl(m)Z)m*Z*m+Z+m,Z,ddl-m.Z.m/Z/m0Z0m1Z1dd l2m3Z3dd l4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;dd l<m=Z=m>Z>m?Z?dd l@mAZAmBZBmCZCmDZDmEZEmFZFe e eGeGfge dfZHed e?���ZIede?e>��ZJedd���ZKedee=eLf���ZMerddlNmOZOGd�de��ZPGd�de��ZQeePeQfZRGd�de+e/e.e0��ZSeSZTGd�de��ZUGd�d��ZVGd�d��ZWGd�d e��ZXGd!�d"e��ZYeeXeYfZZeeeeGe[fd#feeGeffZ\ee\Z]Gd$�d%eS��Z^dS)&�N)� TYPE_CHECKING�Any� AsyncIterator� Awaitable�Callable�Dict�Iterable�List�Mapping�MutableMapping�Optional�Protocol�Set�Tuple�Type� TypedDict�TypeVar�Union�cast)�_RedisCallbacks�_RedisCallbacksRESP2�_RedisCallbacksRESP3�bool_ok)� Connection�ConnectionPool� SSLConnection�UnixDomainSocketConnection��Lock)�Retry)�EMPTY_RESPONSE� NEVER_DECODE� AbstractRedis�CaseInsensitiveDict)�AsyncCoreCommands�AsyncRedisModuleCommands�AsyncSentinelCommands� list_or_args)�CredentialProvider)�ConnectionError�ExecAbortError� PubSubError� RedisError� ResponseError� TimeoutError� WatchError)�ChannelT� EncodableT�KeyT)�HIREDIS_AVAILABLE�_set_info_logger�deprecated_function�get_lib_version�safe_str� str_if_bytes�_KeyT)�bound�_ArgT�_RedisT�Redis�_NormalizeKeysT)�Scriptc��eZdZdefd�ZdS)�ResponseCallbackProtocol�responsec ��dS�N���selfrC�kwargss �d/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/redis/asyncio/client.py�__call__z!ResponseCallbackProtocol.__call__U�����N��__name__� __module__� __qualname__rrKrFrMrJrBrBTs!������4��4�4�4�4�4�4rMrBc��eZdZdefd�ZdS)�AsyncResponseCallbackProtocolrCc�� K�dSrErFrGs rJrKz&AsyncResponseCallbackProtocol.__call__Y� �����rMNrNrFrMrJrSrSXs!������:�s�:�:�:�:�:�:rMrScH�6�eZdZUdZeeeefefe d<e drdede de e fd���Z e d edd ed dfd ���Zd dddddddddddddddddddddddddddde��ddddddd�$dededeeefde ede ede ede e de eeeeeffd e ede eded ed!e d"e d#e ed$e d%e ed&e ed'ed(e ed)e ed*e d+e ejd,e ed-e ede d.ed/e ed0e ed1e ed2e ed3e ede e d4e ed5e efFd6�Zd7�Zd8�Zd9ed efd:�Zd;ed<efd=�Zd>�Z d?�Z!d e d@fdA�Z"dsdB�Z#dC�Z$ dtdEe dFe ed dGfdH�Z%ddddI�dJe&dGgee'e(e'ffdKe)dFe edLe dMe ef dN�Z* dudPe)dQe edRedSe dTe edUe ee+dVe d e+fdW�Z,dvdY�Z-dwd[�Z.dxd\�Z/d9ed efd]�Z0d^�Z1d_Z2e3j4e5j6fd`e'dae'd dfdb�Z7dydce e d dfdd�Z8e9dedfdg�h��dydce e d dfdi���Z:dj�Z;dke<dle=fdm�Z>dn�Z?doe<dpeeeffdq�Z@dS)zr>a� Implementation of the Redis protocol. This abstract class provides a Python interface to all Redis commands and an implementation of the Redis protocol. Pipelines derive from this, implementing how the commands are sent and received to the Redis server. Based on configuration, an instance will either use a ConnectionPool, or Connection object to talk to redis. �response_callbacksFN�url�single_connection_client�auto_close_connection_poolc ��tj|fi|��}|||���}|�"tjt d����nd}||_|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 unix://[username@]/path/to/socket.sock?db=0[&password=password] 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> - ``unix://``: creates a Unix Domain Socket connection. 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. There are several ways to specify a database number. The first value found will be used: 1. A ``db`` querystring option, e.g. redis://localhost?db=0 2. If using the redis:// or rediss:// schemes, the path argument of the url, e.g. redis://localhost/0 3. A ``db`` keyword argument to this function. If none of these options are specified, the default db=0 is used. 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 the ``ConnectionPool``'s class initializer. In the case of conflicting arguments, querystring arguments always win. ��connection_poolrYN��"auto_close_connection_pool" is deprecated since version 5.0.1. Please create a ConnectionPool explicitly and provide to the Redis() constructor instead.T)r�from_url�warnings�warn�DeprecationWarningrZ)�clsrXrYrZrIr]�clients rJr_zRedis.from_urlps���d)�1�#�@�@��@�@����+�%=� � � �� &� 1� �M�"�B��� � � � �*.� &�,F��)�� rMrcr]�returnc�,�||���}d|_|S)z� Return a Redis client from the given connection pool. The Redis client will take ownership of the connection pool and close it when the Redis client is closed. )r]T)rZ)rcr]rds rJ� from_poolzRedis.from_pool�s,����+� � � ��-1��)�� rM� localhosti�rzutf-8�strict�requiredzredis-py�)$�host�port�db�password�socket_timeout�socket_connect_timeout�socket_keepalive�socket_keepalive_optionsr]�unix_socket_path�encoding�encoding_errors�decode_responses�retry_on_timeout�retry_on_error�ssl� ssl_keyfile� ssl_certfile� ssl_cert_reqs� ssl_ca_certs� ssl_ca_data�ssl_check_hostname�ssl_min_version� ssl_ciphers�max_connectionsrY�health_check_interval� client_name�lib_name� lib_version�username�retryrZ�redis_connect_func�credential_provider�protocolrlrmrnrorprqrrrsrtrurvrwrxryrzr{r|r}r~rr�r�r�r�r�r�r�r�r�r�r�r�c$ �t�|!�"tjtd����nd}!| s�|sg}|dur|�t��id|�d|�d|�d|#�d|�d | �d | �d | �d |�d |�dt j| ���d|�d|�d|�d|�d|�d|"�d|$i�}%| �|%�| td���nA|%�|||||d���|r$|%�t||||||||d� ��|!|_ tdi|%��} nd|_ | |_ ||_ d|_tt ��|_|j j�d��dvr |j�t(��n|j�t*��t-j��|_dS)a4 Initialize a new Redis client. To specify a retry policy for specific errors, first set `retry_on_error` to a list of the error/s to retry on, then set `retry` to a valid `Retry` object. To retry on TimeoutError, `retry_on_timeout` can also be set to `True`. Nr^Trnr�ror�rprurvrwrxryr�r�r�r�r�r�r�r�)�path�connection_class)rlrmrqrrrs) r�r{r|r}r~rr�r�r�F)�3�rF)r`rarb�appendr/�copy�deepcopy�updaterrrZrr]rY� connectionr$rrW�connection_kwargs�getrr�asyncior�_single_conn_lock)&rHrlrmrnrorprqrrrsr]rtrurvrwrxryrzr{r|r}r~rr�r�r�r�rYr�r�r�r�r�r�rZr�r�r�rIs& rJ�__init__zRedis.__init__�s���f &� 1� �M�"�B��� � � � �*.� &��A 4�!� $�!#���4�'�'��%�%�l�3�3�3���b���H���H��&�':� � !�.� � �H� �"�?��#�$4��#�$4��!�.�����u�-�-��"�?��(�)>���{���H�� �{�!�"%�&8�#�$�H�%��F�* �+�� � � 0�,F�������� � � $� $�2H�,<�4L� ������ ��M�M�0=�+6�,8�-:�,8�+6�2D�/>�+6� � � � � �/I�D� +�,�6�6�v�6�6�O�O�/4�D� +�.���(@��%�04���"5�o�"F�"F��� � � 1� 5� 5�j� A� A�X� M� M� � #� *� *�+?� @� @� @� @� � #� *� *�+?� @� @� @� ")�������rMc�L�d|jj�d|jj�d|j�d�S)N�<�.�(z)>)� __class__rPrOr]�rHs rJ�__repr__zRedis.__repr__WsC�� +���)� +� +�D�N�,C� +� +��$� +� +� +� rMc�N�|������SrE)� initialize� __await__r�s rJr�zRedis.__await__]s����� � �*�*�,�,�,rMrHc���K�|jr^|j4�d{V��|j�%|j�d���d{V��|_ ddd���d{V��n#1�d{V��swxYwY|S)N�_)rYr�r�r]�get_connectionr�s rJr�zRedis.initialize`s*���� � (� U��-� U� U� U� U� U� U� U� U��?�*�,0�,@�,O�,O�PS�,T�,T�&T�&T�&T�&T�&T�&T�D�O�T� U� U� U� U� U� U� U� U� U� U� U� U� U� U� U� U� U� U� U� U� U� U� U���� U� U� U� U�� s�-A� A!�$A!�command�callbackc��||j|<dS)zSet a custom Response CallbackN)rW)rHr�r�s rJ�set_response_callbackzRedis.set_response_callbackgs��+3����(�(�(rMc�4�|j���S)z!Get the connection pool's encoder)r]� get_encoderr�s rJr�zRedis.get_encoderks���#�/�/�1�1�1rMc��|jjS)z'Get the connection's key-word arguments)r]r�r�s rJ�get_connection_kwargszRedis.get_connection_kwargsos���#�5�5rMr c�P�|����d��S�Nr�)r�r�r�s rJ� get_retryzRedis.get_retryss"���)�)�+�+�/�/��8�8�8rMc��|����d|i��|j�|��dSr�)r�r�r]� set_retry)rHr�s rJr�zRedis.set_retryvsD�� �"�"�$�$�+�+�W�e�,<�=�=�=� ��&�&�u�-�-�-�-�-rMc�(�t|||��dS)a This function can be used to add externally defined redis modules, and their namespaces to the redis client. funcname - A string containing the name of the function to create func - The function, being added to this class. ex: Assume that one has a custom redis module named foomod that creates command named 'foo.dothing' and 'foo.anotherthing' in redis. To load function functions into this namespace: from redis import Redis from foomodule import F r = Redis() r.load_external_module("foo", F) r.foo().dothing('your', 'arguments') For a concrete example see the reimport of the redisjson module in tests/test_connection.py::test_loading_external_modules N)�setattr)rH�funcname�funcs rJ�load_external_modulezRedis.load_external_modulezs��* ��h��%�%�%�%�%rMT� transaction� shard_hint�Pipelinec�:�t|j|j||��S)a_ Return a new pipeline object that can queue multiple commands for later execution. ``transaction`` indicates whether all commands should be executed atomically. Apart from making a group of operations atomic, pipelines are useful for reducing the back-and-forth overhead between the client and server. )r�r]rW)rHr�r�s rJ�pipelinezRedis.pipeline�s%��� � �$�"9�;� � � � rM)r��value_from_callable� watch_delayr��watchesr�r�c��K�|�d|��4�d{V��} |r|j|��d{V��||��}tj|��r|�d{V��}|����d{V��}|r|n| cddd���d{V��S#t $r%|� |dkrt j|���d{V��Y��wxYw#1�d{V��swxYwYdS)z� Convenience method for executing the callable `func` as a transaction while watching all keys specified in `watches`. The 'func' callable should expect a single argument which is a Pipeline object. TNr)r��watch�inspect� isawaitable�executer0r��sleep) rHr�r�r�r�r��pipe� func_value� exec_values rJr�zRedis.transaction�s������=�=��z�2�2� � � � � � � �d� � ��3�(�d�j�'�2�2�2�2�2�2�2�2�!%��d���J��*�:�6�6�6�+5�%5�%5�%5�%5�%5�%5� �'+�|�|�~�~�!5�!5�!5�!5�!5�!5�J�)<�L�:�:�*�L� � � � � � � � � � � � � � ��"����"�.�;��?�?�%�m�K�8�8�8�8�8�8�8�8�8��H����� � � � � � � � � � ���� � � � � � s/�C�AB�,B=�:C�<B=�=C� C � C 皙�����?�name�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)r�r�r�r�r�r)rHr�r�r�r�r�r�r�s rJ�lockz Redis.lock�s>��| � ��J��z� � ����-�%� � � � rM�PubSubc �&�t|jfi|��S)z� Return a Publish/Subscribe object. With this object, you can subscribe to channels and listen for messages that get published to them. )r�r])rHrIs rJ�pubsubz Redis.pubsubs�� �d�*�5�5�f�5�5�5rM�Monitorc�*�t|j��SrE)r�r]r�s rJ�monitorz Redis.monitors���t�+�,�,�,rMc�:�|�|jd���S)NTr\)r�r]r�s rJrdz Redis.clients%���~�~� �0�4�� � � rMc��:K�|����d{V��SrE)r�r�s rJ� __aenter__zRedis.__aenter__s(�����_�_�&�&�&�&�&�&�&�&�&rMc��>K�|����d{V��dSrE��aclose�rH�exc_type� exc_value� tracebacks rJ� __aexit__zRedis.__aexit__�,�����k�k�m�m���������rMzUnclosed Redis client�_warn�_grlc� �t|d��rq|j�l|d|��t|��� ||jd�}|���|��n#t $rYnwxYw|j���dSdSdS)Nr�zUnclosed client session )�source)rd�message)�hasattrr��ResourceWarning� _DEL_MESSAGE�call_exception_handler� RuntimeError�_close)rHr�r��contexts rJ�__del__z Redis.__del__ s��� �4�� &� &� %�D�O�,G� �E�5�T�5�5��t� T� T� T� T� �%)�d�6G�H�H������-�-�g�6�6�6�6��� � � ��� ���� �O� "� "� $� $� $� $� $� %� %�,G�,Gs�'A� A$�#A$�close_connection_poolc���K�|j}|r'd|_|j�|���d{V��|s |�(|jr#|j����d{V��dSdSdS)au Closes Redis client connection Args: close_connection_pool: decides whether to close the connection pool used by this Redis client, overriding Redis.auto_close_connection_pool. By default, let Redis.auto_close_connection_pool decide whether to close the connection pool. N)r�r]�releaserZ� disconnect)rHr��conns rJr�z Redis.aclose.s�������� � 5�"�D�O��&�.�.�t�4�4� 4� 4� 4� 4� 4� 4� 4� � 4� !� )�d�.M� )��&�1�1�3�3� 3� 3� 3� 3� 3� 3� 3� 3� 3� *� )� )� )rM�5.0.1�Use aclose() instead�close��version�reasonr�c��@K�|�|���d{V��dS)zA Alias for aclose(), for backwards compatibility Nr�)rHr�s rJr�z Redis.closeBs3���� �k�k�/�0�0�0�0�0�0�0�0�0�0�0rMc��PK�|j|��d{V��|j||fi|���d{V��S)z7 Send a command and parse the response N)� send_command�parse_response)rHr�� command_name�args�optionss rJ�_send_command_parse_responsez"Redis._send_command_parse_responseIsY���� �d���&�&�&�&�&�&�&�&�(�T�(��|�G�G�w�G�G�G�G�G�G�G�G�GrMr��errorc��K�|����d{V��|j�$t|t|j����dur|�dS)z� Close the connection and raise an exception if retry_on_error is not set or the error is not one of the specified error types NF)r�ry� isinstance�tuple�rHr�rs rJ�_disconnect_raisezRedis._disconnect_raisePsa���� �o�o���������� � � '��%��t�':�!;�!;�<�<��E�E��K�F�ErMc��V�����K������d{V���j}�d��jp|j�fi����d{V����jr�j����d{V�� �j������fd���fd����d{V�� �jr�j� ���js|� ����d{V��SS#�jr�j� ���js|� ����d{V��wwxYw)z.Execute a command and return a parsed responseNrc�(���j��g��Ri���SrE�r�rrr�rrHs�����rJ�<lambda>z'Redis.execute_command.<locals>.<lambda>is6���9��9��,��)-����18���rMc�0�����|��SrE)r �rr�rHs ��rJrz'Redis.execute_command.<locals>.<lambda>ls���d�4�4�T�5�A�A�rM) r�r]r�r�rYr��acquirer��call_with_retryr�)rHrr�poolrr�s``` @@rJ�execute_commandzRedis.execute_command^s�����������o�o�����������#���A�w� ���T�(;��(;�L�(T�(T�G�(T�(T�"T�"T�"T�"T�"T�"T�� � (� 3��(�0�0�2�2� 2� 2� 2� 2� 2� 2� 2� )���3�3���������B�A�A�A�A� �������� ��,� 1��&�.�.�0�0�0��?� )��l�l�4�(�(�(�(�(�(�(�(�(�(� )���,� 1��&�.�.�0�0�0��?� )��l�l�4�(�(�(�(�(�(�(�(�(�(� )���s �3+C#�#AD(r�rc��"K� t|vr7|�d����d{V��}|�t��n|����d{V��}n'#t$rt|vr|tcYS�wxYwt|vr|�t��|�dd��||jvrGt t|��}|j||fi|��}tj |��r|�d{V��n|S|S)z'Parses a response from the Redis serverT)�disable_decodingN�keys) r"� read_response�popr.r!rWr�strr�r�)rHr�rrrC�retvals rJrzRedis.parse_responsetsM���� ��w�&�&�!+�!9�!9�4�!9�!P�!P�P�P�P�P�P�P��� � �L�)�)�)�)�!+�!9�!9�!;�!;�;�;�;�;�;�;����� � � ���(�(��~�.�.�.�.� � ���� �W� $� $� �K�K�� '� '� '� � � �F�D�!�!�!� �4�2� 2� 2���\�2�2�L�:�T�,�\�:�8�O�O�w�O�O�F�#*�#6�v�#>�#>�J��<�<�<�<�<�<�<�F� J��s�AA� B�B)FN)r�r reN)TN)Nr�TNNT)rer�)rer�)rer>rE)ArOrPrQ�__doc__r rr�bytes�ResponseCallbackT�__annotations__� classmethod�boolr r_rrrgr7�int�floatr �listrz� TLSVersionr r)r�r�r�r=r�r�r�r�r�r�r�r�rrrr3r�rr�r�r�rdr�r�r�r`rar��get_running_loopr�r�r6r�rr� Exceptionr rrrFrMrJr>r>_s.������� � �'�u�S�%�Z�'8�:K�'K�L�L�L�L��*/�59� B�B� �B�#'�B�%-�T�N� B�B�B��[�B�H� � �'�]� �'� � � � � ��[� �$ ���"&�*.�26�+/�NR�48�*.��'�!&�!&�)-��%)�&*�'�&*�%)�#(�48�%)�)-�).�%&�%)�",�%4�_�%6�%6�"&�!%�59��<@�"#�MP0�P0�P0��P0�� P0� �#�s�(�O� P0� �3�-� P0�!���P0�!)���P0�#�4�.�P0�#+�7�3��c�5�j�8I�3I�+J�"K�P0�"�.�1�P0�#�3�-�P0��P0��P0��P0� �!P0�"!���#P0�$�%P0�&�c�]�'P0�(�s�m�)P0�*�+P0�,�s�m�-P0�.�c�]�/P0�0!�1P0�2"�#�.�1�3P0�4�c�]�5P0�6"�#��7P0�8#'�9P0�: #�;P0�<�c�]�=P0�>�3�-�?P0�@�c�]�AP0�B�3�-�CP0�D���EP0�F%-�T�N�GP0�J&�&8�9�KP0�L�3�-�MP0�P0�P0�P0�d � � � -�-�-��w��7�����4�S�4�<M�4�4�4�4�2�2�2�6�6�6�9�8�G�,�9�9�9�9�.�.�.�.�&�&�&�0EI�  �  ��  �4<�S�M�  � �  �  �  �  �$%)�$)�'+� ���� �|�U�3� �#��+>�%?�?�@�����S�M� � "� � �e�_� ����@$(���,0�+/�!�H �H ��H ��%��H �� H � � H � #�5�/� H ��T�$�Z�(�H ��H � �H �H �H �H �T6�6�6�6�-�-�-�-� � � � � '�w�'�7�'�'�'�'����+�L� �]��,� %� %�� %�� %� � %� %� %� %�4�4�(�4�.�4�D�4�4�4�4�(���1G�g�V�V�V�1�1��$��1�4�1�1�1�W�V�1� H�H�H� �J� �y� � � � �)�)�)�,�$��49�#�u�*�4E������rMc�L�eZdZUeed<eed<eed<eed<eed<eed<dS)�MonitorCommandInfo�timern�client_address� client_port� client_typer�N)rOrPrQr&r"r%rrFrMrJr,r,�sO������� �K�K�K� �G�G�G������������� �L�L�L�L�LrMr,c��eZdZdZejd��Zejd��Zdefd�Z d�Z d�Z d�Z d e fd �Zd ee fd �Zd S) r�z� Monitor is useful for handling the MONITOR command to the redis server. next_command() method returns one command from monitor listen() method yields commands from monitor. z\[(\d+) (.*?)\] (.*)z"(.*?)(?<!\\)"r]c�"�||_d|_dSrE)r]r�)rHr]s rJr�zMonitor.__init__�s��.���04����rMc��fK�|j�'|j�d���d{V��|_dSdS)N�MONITOR)r�r]r�r�s rJ�connectzMonitor.connect�sD���� �?� "�$(�$8�$G�$G� �$R�$R�R�R�R�R�R�R�D�O�O�O� #� "rMc���K�|����d{V��|j�d���d{V��|j����d{V��}t |��st d|�����|S)Nr4zMONITOR failed: )r5r�rrrr-�rHrCs rJr�zMonitor.__aenter__�s������l�l�n�n���������o�*�*�9�5�5�5�5�5�5�5�5�5���6�6�8�8�8�8�8�8�8�8���x� � � <��:��:�:�;�;� ;�� rMc��K�|j����d{V��|j�|j���d{V��dSrE)r�r�r]r�)rHrs rJr�zMonitor.__aexit__�s]�����o�(�(�*�*�*�*�*�*�*�*�*��"�*�*�4�?�;�;�;�;�;�;�;�;�;�;�;rMrec���K�|����d{V��|j����d{V��}t|t��r!|jj�|d���}|�dd��\}}|j� |��}|� ��\}}}d� |j � |����}|�dd��}|dkrd}d } d} n?|�d ��rd }|d d�} d } n|�d d��\}} d } t#|��t%|��|| | |d�S)z)Parse the response from a monitor commandNT��force� �z\"�"�lua��unix��:�tcp)r-rnr.r/r0r�)r5r�rr r �encoder�decode�split� monitor_re�match�groups�join� command_re�findall�replace� startswith�rsplitr&r%) rHrC� command_time� command_data�m�db_id� client_infor�r.r/r0s rJ� next_commandzMonitor.next_command�s������l�l�n�n����������6�6�8�8�8�8�8�8�8�8�� �h�� &� &� L���.�5�5�h�d�5�K�K�H�%-�^�^�C��%;�%;�"� �l� �O� !� !�,� /� /��&'�h�h�j�j�#��{�G��(�(�4�?�2�2�7�;�;�<�<���/�/�%��-�-�� �%� � �"�N��K��K�K� � #� #�F� +� +� �#�N�%�a�b�b�/�K� �K�K�+6�*<�*<�S�!�*D�*D� '�N�K��K��,�'�'��e�*�*�,�&�&��  � � rMc�DK� |����d{V��WV��)z)Listen for commands coming to the server.TN)rVr�s rJ�listenzMonitor.listen�s=���� ,��)�)�+�+�+�+�+�+�+�+� +� +� +� +� ,rMN)rOrPrQr�re�compilerHrLrr�r5r�r�r,rVrrXrFrMrJr�r��s��������� ���3�4�4�J����-�.�.�J�5��5�5�5�5�S�S�S����<�<�<�" �$6�" �" �" �" �H,�m�,>�?�,�,�,�,�,�,rMr�c ���eZdZdZdZdZdZ d8dedee d e d ee fd �Z d �Z d �Zd�Zd�Zeddd���d9d���Zeddd���d9d���Zdefd�Zed���Zdefd�Zd�Zd�Zd�Zd:d"e d#efd$�Zd%�Zd&e de fd'�Z!de"d(e#fd)�Z$de"de%fd*�Z&de"d(e fd+�Z'de%fd,�Z(de)fd-�Z* d;d e d#eefd/�Z+d<de%fd0�Z,d=d1�Z-dd2d3�d4ed5d6eddfd7�Z.dS)>r�a* PubSub provides publish, subscribe and listen support to Redis channels. After subscribing to one or more channels, the listen() method will block until a message arrives on one of the subscribed channels. That message will be returned and it's safe to start listening again. )r��pmessage)� unsubscribe� punsubscribezredis-py-health-checkNFr]r��ignore_subscribe_messages�push_handler_funcc�4�||_||_||_d|_||_||_|j�|j���|_|jjrd|jg|jg|_ nEd|j� |j��g|j� |j��g|_ |j�t��i|_ t��|_i|_t��|_t#j��|_dS)N�pong�pong)r]r�r_r�rEr`r�rw�HEALTH_CHECK_MESSAGE�health_check_response�encoder5�channels�set�pending_unsubscribe_channels�patterns�pending_unsubscribe_patternsr�r�_lock)rHr]r�r_rEr`s rJr�zPubSub.__init__�s�� /���$���)B��&������ �!2��� �<� ��/�;�;�=�=�D�L� �<� (� ���2�3��)�*�D� &� &� �$�,�-�-�d�.G�H�H�I�� �#�#�D�$=�>�>�*�D� &� � !� )� � � � ��� �,/�E�E��)��� �,/�E�E��)��\�^�^�� � � rMc�� K�|SrErFr�s rJr�zPubSub.__aenter__� ����� rMc��>K�|����d{V��dSrEr�r�s rJr�zPubSub.__aexit__r�rMc�V�|jr!|j�|j��dSdSrE)r��deregister_connect_callback� on_connectr�s rJr�zPubSub.__del__s7�� �?� I� �O� 7� 7��� H� H� H� H� H� I� IrMc���K�t|d��sdS|j4�d{V��|jrj|j����d{V��|j�|j��|j�|j���d{V��d|_i|_t��|_ i|_ t��|_ ddd���d{V��dS#1�d{V��swxYwYdS)Nr�) r�rlr�r�rqrrr]r�rgrhrirjrkr�s rJr�z PubSub.aclose!s������t�\�*�*� � �F��:� 6� 6� 6� 6� 6� 6� 6� 6��� '��o�0�0�2�2�2�2�2�2�2�2�2���;�;�D�O�L�L�L��*�2�2�4�?�C�C�C�C�C�C�C�C�C�"&����D�M�03���D� -��D�M�03���D� -� 6� 6� 6� 6� 6� 6� 6� 6� 6� 6� 6� 6� 6� 6� 6� 6� 6� 6� 6� 6� 6� 6� 6� 6���� 6� 6� 6� 6� 6� 6s�B&C� C%�(C%r�r�r�r�rec��>K�|����d{V��dS�z/Alias for aclose(), for backwards compatibilityNr�r�s rJr�z PubSub.close2�.�����k�k�m�m���������rM�resetc��>K�|����d{V��dSrur�r�s rJrwz PubSub.reset7rvrMr�c���K�|j���|j���|jrSi}|j���D]$\}}|||j�|d���<�%|jdi|���d{V��|jrUi}|j���D]$\}}|||j�|d���<�%|j di|���d{V��dSdS)zBRe-subscribe to any channels and patterns previously subscribed toTr:NrF) ri�clearrkrg�itemsrErF� subscriberj� psubscribe)rHr�rg�k�vrjs rJrrzPubSub.on_connect<s>���� �)�/�/�1�1�1� �)�/�/�1�1�1� �=� -��H�� �+�+�-�-� A� A���1�?@����,�,�Q�d�,�;�;�<�<� �$�.�,�,�8�,�,� ,� ,� ,� ,� ,� ,� ,� �=� .��H�� �+�+�-�-� A� A���1�?@����,�,�Q�d�,�;�;�<�<�!�$�/�-�-�H�-�-� -� -� -� -� -� -� -� -� -�  .� .rMc�8�t|jp|j��S)z@Indicates if there are subscriptions to any channels or patterns)r$rgrjr�s rJ� subscribedzPubSub.subscribedNs���D�M�2�T�]�3�3�3rMrc��K�|����d{V��|j}d|j i}|j||jg|�Ri|���d{V��dS)z#Execute a publish/subscribe commandN� check_health)r5r�r��_executer)rHrr�rIs rJrzPubSub.execute_commandSs}�����l�l�n�n���������_� � �d�o�"5�6���d�m�J� �(?�Q�$�Q�Q�Q�&�Q�Q�Q�Q�Q�Q�Q�Q�Q�Q�QrMc��XK�|j�K|j�d|j���d{V��|_|j�|j��n|j����d{V��|j�-ts(|jj � |j��dSdSdS)z5 Ensure that the PubSub is connected Nr�) r�r]r�r��register_connect_callbackrrr5r`r4�_parser�set_pubsub_push_handlerr�s rJr5zPubSub.connect_s����� �?� "�$(�$8�$G�$G��$�/�%�%�������D�O� �O� 5� 5�d�o� F� F� F� F��/�)�)�+�+� +� +� +� +� +� +� +� � !� -�6G� -� �O� #� ;� ;�D�<R� S� S� S� S� S� .� -� -� -rMc���K�|����d{V��|j�$t|t|j����dur|�|����d{V��dS)z� Close the connection and raise an exception if retry_on_error is not set or the error is not one of the specified error types. Otherwise, try to reconnect NF)r�ryr r r5r s rJ�_disconnect_raise_connectz PubSub._disconnect_raise_connectos~�����o�o���������� � � '��%��t�':�!;�!;�<�<��E�E��K��l�l�n�n���������rMc��d�����K��j����fd���fd����d{V��S)aU Connect manually upon disconnection. If the Redis server is down, this will fail and raise a ConnectionError as desired. After reconnection, the ``on_connect`` callback should have been called by the # connection to resubscribe us to any channels and patterns we were previously listening to c�����i���SrErF)rr�rIs���rJrz!PubSub._execute.<locals>.<lambda>�s���G�G�T�,�V�,�,�rMc�0�����|��SrE)r�rs ��rJrz!PubSub._execute.<locals>.<lambda>�s���$�8�8��u�E�E�rMN)r�r)rHr�r�rrIs`````rJr�zPubSub._execute~sf����������Z�/�/� ,� ,� ,� ,� ,� ,� E� E� E� E� E� � � � � � � � � rMTr�blockr�c��*K�|j}|�td���|����d{V��|js|����d{V��|rdn|}|�||j|dd����d{V��}|jr ||jvrdS|S)z3Parse the response from a publish/subscribe commandN�Npubsub connection not set: did you forget to call subscribe() or psubscribe()?FT)r��disconnect_on_error� push_request) r�r�r�� is_connectedr5r�rr�re)rHr�r�r�� read_timeoutrCs rJrzPubSub.parse_response�s�������� �<��F��� � ���!�!�!�!�!�!�!�!�!�� � !��,�,�.�.� � � � � � � �$�1�t�t�'� ���� � � � � %�� '� � � � � � � � �� � %� �(�d�6P�*P�*P��4��rMc���K�|j}|�td���|jrStj�����|jkr'|�d|jd����d{V��dSdSdS)Nr��PINGF)r�) r�r�r�r�r)r-�next_health_checkrrd)rHr�s rJr�zPubSub.check_health�s�������� �<��F��� � � &� ��(�*�*�/�/�1�1�D�4J�J�J��#�#���1��$��� � � � � � � � � �  � �J�JrM�datac�x���|jj�|jj���fd�|���D��S)z� normalize channel/pattern names to be either bytes or strings based on whether responses are automatically decoded. this saves us from coercing the value for each message coming in. c�@��i|]\}}��|����|��SrFrF)�.0r~rrFrfs ��rJ� <dictcomp>z*PubSub._normalize_keys.<locals>.<dictcomp>�s1���>�>�>���A���v�v�a�y�y�!�!�1�>�>�>rM)rErfrFr{)rHr�rFrfs @@rJ�_normalize_keyszPubSub._normalize_keys�s?���� ��$����$��>�>�>�>�>������>�>�>�>rMrIc��K�|rt|df|dd���n|}t�|��}|�|��|jdg|����R��d{V��}|�|��}|j�|��|j� |��|S)aE Subscribe to channel patterns. Patterns supplied as keyword arguments expect a pattern name as the key and a callable as the value. A pattern's callable will be invoked automatically when a message is received on that pattern rather than producing a message via ``listen()``. rr=N� PSUBSCRIBE) r(�dict�fromkeysr�rrr�rjrk�difference_update)rHrrI� parsed_args� new_patterns�ret_vals rJr}zPubSub.psubscribe�s�����=A�J�l�D��G�:�t�A�B�B�x�8�8�8�d� �6:�m�m�K�6P�6P� ����F�#�#�#�,��,�\�P�L�<M�<M�<O�<O�P�P�P�P�P�P�P�P�P���+�+�L�9�9� � � ���\�*�*�*� �)�;�;�L�I�I�I��rMc�&�|r_t|df|dd���}|�t�|�������}n g}|j}|j�|��|jdg|�R�S)zj Unsubscribe from the supplied patterns. If empty, unsubscribe from all patterns. rr=N� PUNSUBSCRIBE) r(r�r�r�rrjrkr�r)rHrr�rjs rJr^zPubSub.punsubscribe�s��� � %�&��Q��z�4����8�<�<�K��+�+�D�M�M�+�,F�,F�G�G�L�L�N�N�H�H��K��}�H� �)�0�0��:�:�:�#�t�#�N�A�[�A�A�A�ArMc��K�|rt|df|dd���nd}t�|��}|�|��|jdg|����R��d{V��}|�|��}|j�|��|j� |��|S)aR Subscribe to channels. Channels supplied as keyword arguments expect a channel name as the key and a callable as the value. A channel's callable will be invoked automatically when a message is received on that channel rather than producing a message via ``listen()`` or ``get_message()``. rr=NrF� SUBSCRIBE) r(r�r�r�rrr�rgrir�)rHrrIr�� new_channelsr�s rJr|zPubSub.subscribe�s�����=A�H�l�D��G�:�t�A�B�B�x�8�8�8�b� ��}�}�[�1�1� ����F�#�#�#�,��,�[�O�<�;L�;L�;N�;N�O�O�O�O�O�O�O�O�O���+�+�L�9�9� � � ���\�*�*�*� �)�;�;�L�I�I�I��rMc��|rLt|d|dd���}|�t�|����}n g}|j}|j�|��|jdg|�R�S)zi Unsubscribe from the supplied channels. If empty, unsubscribe from all channels rr=N� UNSUBSCRIBE)r(r�r�r�rgrir�r)rHrr�rgs rJr]zPubSub.unsubscribe�s��� � %�&�t�A�w��Q�R�R��9�9�K��+�+�D�M�M�+�,F�,F�G�G�H�H��K��}�H� �)�0�0��:�:�:�#�t�#�M�@�K�@�@�@�@rMc�K�|jrE|�|�d����d{V�����d{V��}|�|WV�|j�CdSdS)zBListen for messages on channels this client has been subscribed toT)r�N)r��handle_messagerr7s rJrXz PubSub.listens������o� �!�0�0�t�7J�7J�QU�7J�7V�7V�1V�1V�1V�1V�1V�1V�W�W�W�W�W�W�W�W�H��#�������o� � � � � rM�c��K�|�|du|����d{V��}|r|�||���d{V��SdS)a Get the next message if one is available, otherwise None. If timeout is specified, the system will wait for `timeout` seconds before returning. Timeout should be specified as a floating point number or None to wait indefinitely. N)r�r�)rr�)rHr_r�rCs rJ� get_messagezPubSub.get_messagesm�����,�,�G�t�O�g�,�V�V�V�V�V�V�V�V�� � R��,�,�X�7P�Q�Q�Q�Q�Q�Q�Q�Q� Q��trMc�(�|�d|gndg}|j|�S)z' Ping the Redis server Nr��r)rHr�rs rJ�pingz PubSub.pings*��%,�$7��� � �f�X��#�t�#�T�*�*rMc��zK�|�dSt|t��r|dkrd|gnddg}t|d��}|dkr||d|d|d d �}n'|d kr|dd|dd �}n|d|d|dd �}||jvr�|d krG|d}||jvr5|j�|��|j�|d��nF|d}||jvr5|j�|��|j �|d��||j vr|dkr"|j� |d d��}n!|j � |dd��}|r3tj |��r||���d{V��n ||��dSn|d kr |s|jrdS|S)z� Parses a pub/sub message. If the channel or pattern was subscribed to with a message handler, the handler is invoked instead of a parsed message being returned. NsPONGrcrMrr\r=rkr�)�type�pattern�channelr�rbr^r�r�)r r r9�UNSUBSCRIBE_MESSAGE_TYPESrk�removerjrrirg�PUBLISH_MESSAGE_TYPESr�r��iscoroutinefunctionr_)rHrCr_� message_typer�r�r��handlers rJr�zPubSub.handle_message%sS���� � ��4� �h�� &� &� V�.6�'�.A�.A���*�*��QT�~�H�#�H�Q�K�0�0� � �:� %� %�$�#�A�;�#�A�;� �� � ��G�G� �V� #� #�$��� �� � ��G�G�%��#�A�;� �� � ��G� �4�9� 9� 9��~�-�-�"�1�+���d�?�?�?��5�<�<�W�E�E�E��M�%�%�g�t�4�4�4��"�1�+���d�?�?�?��5�<�<�W�E�E�E��M�%�%�g�t�4�4�4� �4�5� 5� 5��z�)�)��-�+�+�G�I�,>��E�E����-�+�+�G�I�,>��E�E��� ��.�w�7�7�%�!�'�'�*�*�*�*�*�*�*�*�*�*��G�G�$�$�$��t�  � �V� #� #�)� �D�,J� ��t��rMg�?)�exception_handler� poll_timeoutr��PSWorkerThreadExcHandlerTr�c��"K�|j���D]\}}|�td|�d�����|j���D]\}}|�td|�d�����|����d{V�� |�d|����d{V��nQ#t j$r�t$r5}|��|||��}tj |��r|�d{V��Yd}~nd}~wwxYwt j d���d{V����)a�Process pub/sub messages using registered callbacks. This is the equivalent of :py:meth:`redis.PubSub.run_in_thread` in redis-py, but it is a coroutine. To launch it as a separate task, use ``asyncio.create_task``: >>> task = asyncio.create_task(pubsub.run()) To shut it down, use asyncio cancellation: >>> task.cancel() >>> await task Nz Channel: 'z' has no handler registeredz Pattern: 'T)r_r�r) rgr{r,rjr5r�r��CancelledError� BaseExceptionr�r�r�)rHr�r�r�r�r��e�ress rJ�runz PubSub.rungs�����&!%� � 3� 3� 5� 5� U� U� �G�W���!�"S�w�"S�"S�"S�T�T�T�� $� � 3� 3� 5� 5� U� U� �G�W���!�"S�w�"S�"S�"S�T�T�T���l�l�n�n�������� #� ��&�&�.2�L�'�������������)� � � �� � � � �$�,��'�'��4�0�0���&�s�+�+���I�I�I�I�I�I�I����������  �����-��"�"� "� "� "� "� "� "� "� #s�B%�%C3�>+C.�.C3)NFNN�reN)Tr)Fr�rE)F)/rOrPrQrr�r�rdrr rr$rr�r�r�r�r�r6r�rwrrr�propertyr�r2rr5r�r�r&rr�r?r�r1� PubSubHandlerr}rr^r|r]rrXr�r�r�r�rFrMrJr�r��sp��������4�� ?��2�� %)�*/��04� "$�"$�'�"$��S�M�"$�$(� "$� $�H�-� "$�"$�"$�"$�H������I�I�I�6�6�6�"���1G�g�V�V�V����W�V�����1G�g�V�V�V����W�V��.�:�.�.�.�.�$�4�4��X�4� R�:� R� R� R� R�T�T�T� � � �  �  �  ���$�������8��� ?�O�?��?�?�?�?��h��-�����* B�(� B�y� B� B� B� B��X�������* A�I� A� A� A� A��m�����SV� � �)-� �@H��� � � � �+�+�I�+�+�+�+�@�@�@�@�JDH�!� *#�*#�*#�$�$?�@�*#�� *#� � *#�*#�*#�*#�*#�*#rMr�c��eZdZdedefd�ZdS)�PubsubWorkerExceptionHandlerr�r�c��dSrErF�rHr�r�s rJrKz%PubsubWorkerExceptionHandler.__call__�rLrMN�rOrPrQr�r�rKrFrMrJr�r��s&������=�-�=��=�=�=�=�=�=rMr�c��eZdZdedefd�ZdS)�!AsyncPubsubWorkerExceptionHandlerr�r�c�� K�dSrErFr�s rJrKz*AsyncPubsubWorkerExceptionHandler.__call__�rUrMNr�rFrMrJr�r��s&������C� �C�v�C�C�C�C�C�CrMr�.c ���eZdZdZhd�Zdedeeee fe fde de efd�Z ded efd �Zd �Zd �Zd Zd�Zd�Zd�Zd�Zd0d�Zd�Zd ededffd�Zd�Zd�Zd�Zdedefd�Z dedede fd�Z!dede"e#fd�Z$d e%d!e&d"e"e'd dfd#�Z(ded$eee ff�fd%� Z)d&�Z*d'ed(e%fd)�Z+d1de fd+�Z,d,�Z-d-e.fd.�Z/d/�Z0�xZ1S)2r�a_ Pipelines provide a way to transmit multiple commands to the Redis server in one transmission. This is convenient for batch processing, such as saving all the values in a list to Redis. All commands executed within a pipeline are wrapped with MULTI and EXEC calls. This guarantees all commands executed in the pipeline will be executed atomically. Any command raising an exception does *not* halt the execution of subsequent commands in the pipeline. Instead, the exception is caught and its instance is placed into the response list returned by execute(). Code iterating over the response list should be able to deal with an instance of an exception as a potential value. In general, these will be ResponseError exceptions, such as those raised when issuing a command on a key of a different datatype. >�EXEC�DISCARD�UNWATCHr]rWr�r�c��||_d|_||_||_||_d|_g|_t��|_d|_ dS)NF) r]r�rW�is_transactionr��watching� command_stackrh�scripts�explicit_transaction)rHr]rWr�r�s rJr�zPipeline.__init__�sR�� /������"4���)���$����� �,.���&)�e�e�� �$)��!�!�!rMrHrec�� K�|SrErFr�s rJr�zPipeline.__aenter__�rnrMc��>K�|����d{V��dSrE�rwr�s rJr�zPipeline.__aexit__�s,�����j�j�l�l���������rMc�N�|������SrE)� _async_selfr�r�s rJr�zPipeline.__await__�s �����!�!�+�+�-�-�-rMzUnclosed Pipeline clientc�*�t|j��SrE)�lenr�r�s rJ�__len__zPipeline.__len__�s���4�%�&�&�&rMc��dS)z1Pipeline instances should always evaluate to TrueTrFr�s rJ�__bool__zPipeline.__bool__�s���trMc�� K�|SrErFr�s rJr�zPipeline._async_self�rnrMc���K�g|_t��|_|jr~|jrw |j�d���d{V��|j����d{V��n6#t$r)|jr|j����d{V��YnwxYwd|_d|_ |jr.|j � |j���d{V��d|_dSdS)Nr�F) r�rhr�r�r�rrr*r�r�r]r�r�s rJrwzPipeline.reset�s0��������u�u�� � �=� 7�T�_� 7� 7��o�2�2�9�=�=�=�=�=�=�=�=�=��o�3�3�5�5�5�5�5�5�5�5�5�5��"� 7� 7� 7��?�7��/�4�4�6�6�6�6�6�6�6�6�6��� 7���� �� �$)��!� �?� #��&�.�.�t��?�?� ?� ?� ?� ?� ?� ?� ?�"�D�O�O�O� #� #s�?A,�,0B�BNc��>K�|����d{V��dS)z5Alias for reset(), a standard method name for cleanupNr�r�s rJr�zPipeline.aclose�s,�����j�j�l�l���������rMc�l�|jrtd���|jrtd���d|_dS)z� Start a transactional block of the pipeline after WATCH commands are issued. End the transactional block with `execute`. z"Cannot issue nested calls to MULTIz:Commands without an initial WATCH have already been issuedTN)r�r-r�r�s rJ�multizPipeline.multi�sO�� � $� C��A�B�B� B� � � ��L��� �%)��!�!�!rMc�j�|js |ddkr|js |j|i|��S|j|i|��S)Nr�WATCH)r�r��immediate_execute_command�pipeline_execute_command)rHrrIs rJrzPipeline.execute_command sU�� �M� C�T�!�W��/�/��9R�/�1�4�1�4�B�6�B�B� B�,�t�,�d�=�f�=�=�=rMc��*K�|����d{V��|jr)|����d{V��td���|j�$t |t |j����dur|����d{V���dS)z� Close the connection, reset watching state and raise an exception if we were watching, if retry_on_error is not set or the error is not one of the specified error types. N�=A ConnectionError occurred on while watching one or more keysF)r�r�r�r0ryr r r s rJ�_disconnect_reset_raisez Pipeline._disconnect_reset_raises������o�o���������� �=� ��+�+�-�-� � � � � � � ��O��� � � � '��%��t�':�!;�!;�<�<��E�E��+�+�-�-� � � � � � � � �F�ErMc��������K��d��j��s-�j���j���d{V�����_�j������fd���fd����d{V��S)z� Execute a command immediately, but don't auto-retry on a ConnectionError if we're already WATCHing a variable. Used when issuing WATCH or subsequent commands retrieving their values but before MULTI is called. rNc�(���j��g��Ri���SrErrs�����rJrz4Pipeline.immediate_execute_command.<locals>.<lambda>:s6���5�D�5��l��%)����-4���rMc�0�����|��SrE)r�rs ��rJrz4Pipeline.immediate_execute_command.<locals>.<lambda>=s���$�6�6�t�U�C�C�rM)r�r]r�r�r�r)rHrrrr�s```@@rJr�z"Pipeline.immediate_execute_command)s�����������A�w� ����� #��-�<�<��d�o���������D�#�D�O��Z�/�/� � � � � � � � � D� C� C� C� C�  � � � � � � � � rMc�>�|j�||f��|S)ar Stage a command to be executed when execute() is next called Returns the current Pipeline object back so commands can be chained together, such as: pipe = pipe.set('foo', 'bar').incr('baz').decr('bang') At some other point, you can then run: pipe.execute(), which will execute all commands queued in the pipe. )r�r�)rHrrs rJr�z!Pipeline.pipeline_execute_command@s$�� ��!�!�4��/�2�2�2�� rMr��commandsc��K�dif}dif}|g|�|�R}|�d�|D����}|�|���d{V��g} |�|d���d{V��n.#t$r!} |�d| f��Yd} ~ nd} ~ wwxYwt |��D]�\} } t | dvr)|�| | dt f���= |�|d���d{V���[#t$rA} |�| | dz| d��|�| | f��Yd} ~ ��d} ~ wwxYw |�|d���d{V��} n$#t$r} |r|dd| ��d} ~ wwxYwd|_ | �td��d�|D]\} } | � | | ���t| ��t|��kr6|j r|j ����d{V��td ��d�|r|�|| ��g}t!| |��D]�\}}t#|t$��s\|\}}|d}|�d d��||jvr0|j||fi|��}t+j|��r|�d{V��}|�|����|S) N)�MULTI)r�c3�2K�|]\}}t|v�|V��dSrE)r!)r�rrs rJ� <genexpr>z0Pipeline._execute_transaction.<locals>.<genexpr>Us9����, �, �"�T�7�n�G�.K�.K�D�.K�.K�.K�.K�, �, rMr�rr=FzWatched variable changed.z6Wrong number of response items from pipeline executionr)� pack_commands�send_packed_commandrr.r�� enumerater!�annotate_exceptionr+r�r0�insertr�r�r��raise_first_error�zipr r*rrWr�r�)rHr�r��raise_on_error�pre�post�cmds�all_cmds�errors�err�ir�rCr�r��r�cmdrrrs rJ�_execute_transactionzPipeline._execute_transactionOs�����$�R�(��#�R����%�h�%��%�%���+�+�, �, �&*�, �, �, � � ���,�,�X�6�6�6�6�6�6�6�6�6���  $��%�%�j�#�6�6� 6� 6� 6� 6� 6� 6� 6� 6��� $� $� $� �M�M�1�c�(� #� #� #� #� #� #� #� #����� $����$�H�-�-� ,� ,�J�A�w�����+�+�� � �q�'�!�*�^�"<�=�>�>�>�>�,��-�-�j�#�>�>�>�>�>�>�>�>�>�>��$�,�,�,��+�+�C��Q���� �C�C�C��M�M�1�c�(�+�+�+�+�+�+�+�+�����,����  �!�0�0��S�A�A�A�A�A�A�A�A�H�H��� � � �� ,��Q�i��l��+� ����� ���� �� � � ��8�9�9�t� C�� "� "�D�A�q� �O�O�A�q� !� !� !� !� �x�=�=�C��M�M� )� )��� 3��o�0�0�2�2�2�2�2�2�2�2�2��H���� � � 7� � "� "�8�X� 6� 6� 6����(�H�-�-� � �F�A�s��a��+�+� $� #� ��g�#�A�w� �� � �F�D�)�)�)��4�#:�:�:�=��/� �=�a�K�K�7�K�K�A��*�1�-�-�$�"#�G�G�G�G�G�G�� �K�K��N�N�N�N�� sH�A-�- B�7B�B�(D� E�7E � E�E1�1 F�;F � Frc��xK�|�d�|D����}|�|���d{V��g}|D]`\}} |�|j||dfi|���d{V�����5#t$r}|�|��Yd}~�Yd}~wwxYw|r|�||��|S)Nc��g|]\}}|��SrFrF)r�rr�s rJ� <listcomp>z.Pipeline._execute_pipeline.<locals>.<listcomp>�s��,J�,J�,J�g�d�A�T�,J�,J�,JrMr)r�r�r�rr.r) rHr�r�rrrCrrr�s rJ�_execute_pipelinezPipeline._execute_pipeline�s�����+�+�,J�,J��,J�,J�,J�K�K���,�,�X�6�6�6�6�6�6�6�6�6���%� #� #�M�D�'� #����-�$�-�j�$�q�'�M�M�W�M�M�M�M�M�M�M�M������!� #� #� #�����"�"�"�"�"�"�"�"����� #���� � 7� � "� "�8�X� 6� 6� 6��s�.A6�6 B�B�BrCc��t|��D]B\}}t|t��r(|�||dz||d��|��CdS)Nr=r)r�r r.r�)rHr�rCr r s rJrzPipeline.raise_first_error�sg���h�'�'� � �D�A�q��!�]�+�+� ��'�'��1�q�5�(�1�+�a�.�A�A�A��� � � rM� exception�numberr�c��d�tt|����}d|�d|�d|j��}|f|jdd�z|_dS)Nr<z Command # z (z) of pipeline caused error: r=)rK�mapr8r)rHrrr�r �msgs rJr�zPipeline.annotate_exception�s[���h�h�s�8�W�-�-�.�.��V�6�V�V�S�V�V�i�n�V�V����)�.����"4�4� ���rMrc���K�t��j||fi|���d{V��}||jvrd|_n |dkrd|_|S)NFr�T)�superr�UNWATCH_COMMANDSr�)rHr�rr�resultr�s �rJrzPipeline.parse_response�si�����.�u�w�w�-�j�,�R�R�'�R�R�R�R�R�R�R�R�� �4�0� 0� 0�!�D�M�M� �W� $� $� �D�M�� rMc��K�t|j��}|j}d�|D��}|dg|�R��d{V��}t|��s4t ||��D]%\}}|s|d|j���d{V��|_�$dSdS)Nc��g|] }|j�� SrF)�sha)r��ss rJrz)Pipeline.load_scripts.<locals>.<listcomp>�s��'�'�'�!���'�'�'rMz SCRIPT EXISTSz SCRIPT LOAD)r'r�r��allr�scriptr)rHr�� immediate�shas�existsr�exists rJ� load_scriptszPipeline.load_scripts�s������t�|�$�$���2� �'�'�w�'�'�'��!�y��8�4�8�8�8�8�8�8�8�8�8���6�{�{� E����0�0� E� E���5��E�"+�)�M�1�8�"D�"D�D�D�D�D�D�D�A�E�� E� E� E� ErMr�rc���K�|����d{V��|jrtd���|j�$t |t |j����dur|����d{V���dS)z� Close the connection, raise an exception if we were watching, and raise an exception if retry_on_error is not set or the error is not one of the specified error types. Nr�F)r�r�r0ryr r rwr s rJ�_disconnect_raise_resetz Pipeline._disconnect_raise_reset�s����� �o�o���������� �=� ��O��� � � � '��%��t�':�!;�!;�<�<��E�E��*�*�,�,� � � � � � � � �F�ErMTc�������K��j��s �jsgS�jr�����d{V���js�jr�j�n�j��j��s-�j � d�j ���d{V�����_tt���� �j�����fd���fd����d{V�� �����d{V��S#�����d{V��wxYw)z0Execute all the commands in the current pipelineNr�c���������SrErF)r�r�r�stacks����rJrz"Pipeline.execute.<locals>.<lambda>s������e�^�<�<�rMc�0�����|��SrE)r(rs ��rJrz"Pipeline.execute.<locals>.<lambda>s���d�:�:�4��G�G�rM)r�r�r�r&r�r�r rr�r]r�r�rrr�rrw)rHrr�r�r+s``@@@rJr�zPipeline.execute�s}����������"��� �T�]� ��I� �<� &��#�#�%�%� %� %� %� %� %� %� %� � � -�$�";� -��/�G�G��,�G����� #��-�<�<�W�d�o�V�V�V�V�V�V�V�V�D�#�D�O��J��%�%�� ���3�3�<�<�<�<�<�<�<�G�G�G�G�G��������� � �*�*�,�,� � � � � � � � ��$�*�*�,�,� � � � � � � � ���s �$*C*�*Dc��@K�|�d���d{V��dS)z^Flushes all previously queued commands See: https://redis.io/commands/DISCARD r�Nr�r�s rJ�discardzPipeline.discards4�����"�"�9�-�-�-�-�-�-�-�-�-�-�-rM�namesc��ZK�|jrtd���|jdg|�R��d{V��S)z$Watches the values at keys ``names``z"Cannot issue a WATCH after a MULTIr�N)r�r-r)rHr/s rJr�zPipeline.watchsN���� � $� C��A�B�B� B�)�T�)�'�:�E�:�:�:�:�:�:�:�:�:�:rMc��NK�|jr|�d���d{V��pdS)z'Unwatches all previously specified keysr�NT)r�rr�s rJ�unwatchzPipeline.unwatchs8�����}�F�t�';�';�I�'F�'F�!F�!F�!F�!F�!F�!F�N�$�NrMr�)T)2rOrPrQrrrr rrr r!r$r r�r=r�r�r�r�r�r�r�rwr�r�rrr�r�r�r� CommandStackTr rr rrr*r%�objectr�rr&r(r�r.r3r�r2� __classcell__)r�s@rJr�r��s���������$6�5�5��*�'�*�+�5��e��+<�>O�+O�P�*�� *� �S�M� *�*�*�*�"�w��7��������.�.�.�.�L�'�'�'�������#�#�#�0���� )� )� )�>� �z�9�Z�0�0� 1�>�>�>�>����2 � � �. � � �L�$�L�0=�L�L�L�L�\�$��0=��OS�����(�-��8�C�=����� 5�"�5�,/�5�:B�6�:J�5� �5�5�5�5��$��49�#�u�*�4E������� E� E� E��*��Y�����.��D�����8.�.�.� ;�$�;�;�;�;� O�O�O�O�O�O�OrMr�)_r�r�r�rYrzr`�typingrrrrrrr r r r r rrrrrrrr�redis._parsers.helpersrrrr�redis.asyncio.connectionrrrr�redis.asyncio.lockr�redis.asyncio.retryr � redis.clientr!r"r#r$�redis.commandsr%r&r'r(�redis.credentialsr)�redis.exceptionsr*r+r,r-r.r/r0� redis.typingr1r2r3� redis.utilsr4r5r6r7r8r9rr�r:r<r=r4r?�redis.commands.corer@rBrSr!r>� StrictRedisr,r�r�r�r�r�r �CommandTr3r�rFrMrJ�<module>rDs������� � � � ����� � � � � � � � �����������������������������������������������,������������ ������������ $�#�#�#�#�#�%�%�%�%�%�%������������� ������������ 1�0�0�0�0�0�������������������4�3�3�3�3�3�3�3�3�3������������������$�s�C�x�.�)�9�T�?�:�;� ����t�$�$�$������z�*�*�� �'�)�7� +� +� +���'�+�7�8�V�;K�3L�M�M�M���+�*�*�*�*�*�*�5�5�5�5�5�x�5�5�5�;�;�;�;�;�H�;�;�;��2�4Q�Q�R��o�o�o�o�o��+�->�@U�o�o�o�d� ����������F,�F,�F,�F,�F,�F,�F,�F,�Rk#�k#�k#�k#�k#�k#�k#�k#�\ >�>�>�>�>�8�>�>�>�D�D�D�D�D��D�D�D�"� �"C�C��� ��u�S�%�Z�(�#�-�.���S��0A�A� B���X�� �qO�qO�qO�qO�qO�u�qO�qO�qO�qO�qOrM
Memory