
    ph                        % S SK r S SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKJ	r	  S SK
Jr  S SKJr  S SKJrJrJrJrJrJrJrJrJrJrJrJrJr  S SKJrJrJrJ r   SSK!J"r"  \"(       a  S SK#r#S S	K#J$r$J%r%J&r&  OSr#Sr%Sr$Sr&SS
K'J(r(  SSK)J*r*J+r+  SSK!J,r,J-r-  \R\                  S:  a  S SK J/r0  OS SK0J/r0  S SK1J2r2  S SK3J4r4  S SK5J6r6  S SK7J8r8J9r9  S SK:J;r;J<r<J=r=J>r>J?r?J@r@JArA  S SKBJCrC  S SKDJErEJFrFJGrG  SSKHJIrIJJrJJKrKJLrLJMrM  SrNSrOSrPSrQSrR " S S\R                  5      rT\TR                  rV\\\L\M\K4      \WS'   \E(       a  \KrXO\LrX " S S \5      rY " S! S"\5      rZ\\Y\Z4   r[ " S# S$5      r\ " S% S&\\5      r] " S' S(\]5      r^ " S) S*5      r_ " S+ S,\\5      r`S-raS.\\b   4S/ jrcS0 rd\" \e\f\f\c\c\e\e\c\d\d\fS1.5      rg\\h\S2\i4   4   \WS3'    " S4 S5\S6S79rjS8\hS.\j4S9 jrk\" S:S;S<9rl " S= S;5      rm " S> S?\m5      rng)@    N)abstractmethod)chain)MappingProxyType)AnyCallableIterableListMappingOptionalProtocolSetTupleType	TypedDictTypeVarUnion)ParseResultparse_qsunquoteurlparse   )SSL_AVAILABLE)
SSLContext
TLSVersionVerifyFlags)TokenInterface)!AsyncAfterConnectionReleasedEventEventDispatcher)deprecated_argsformat_error_message)      r!   )timeout)Retry)	NoBackoff)DEFAULT_RESP_VERSION)CredentialProvider"UsernamePasswordCredentialProvider)AuthenticationError$AuthenticationWrongNumberOfArgsErrorConnectionError	DataError
RedisErrorResponseErrorTimeoutError)
EncodableT)HIREDIS_AVAILABLEget_lib_versionstr_if_bytes)
BaseParserEncoder_AsyncHiredisParser_AsyncRESP2Parser_AsyncRESP3Parser   *   $s   
   
    c                   "    \ rS rSr\" 5       rSrg)	_SentinelR    N)__name__
__module____qualname____firstlineno__objectsentinel__static_attributes__r@   r<   R/home/james-whalen/.local/lib/python3.13/site-packages/redis/asyncio/connection.pyr>   r>   R   s	    xHr<   r>   DefaultParserc                       \ rS rSrSS jrSrg)ConnectCallbackProtocol`   c                     g Nr@   self
connections     rH   __call__ ConnectCallbackProtocol.__call__a   s    #r<   r@   NrQ   AbstractConnectionrA   rB   rC   rD   rR   rG   r@   r<   rH   rK   rK   `   s    =r<   rK   c                       \ rS rSrSS jrSrg)AsyncConnectCallbackProtocold   c                    #    g 7frN   r@   rO   s     rH   rR   %AsyncConnectCallbackProtocol.__call__e   s        r@   NrT   rV   r@   r<   rH   rX   rX   d   s    Cr<   rX   c            .       .   \ rS rSrSrSrSSSSS\SSS\S	SSS
\" 5       SSS\	SSSS.S\
\\4   S\\   S\\   S\\   S\S\
\\4   S\S\S\S\\   S\S\S\\   S\\   S\\   S\\   S\\   S\\   S\\	   S \\   S!\\   S"\\   4,S# jjr\4S$\4S% jjrS& rS' r\S( 5       r\ S) 5       r!S* r"S+ r#S\\   S,S4S- jr$S. r% SWS0\S1\4S2 jjr&S3 r'S4 r(\S5 5       r)\S,\4S6 j5       r*S7\+S,\4S8 jr,S9 r-SXS: jr.SYS0\S,S4S; jjr/SZS<\S,S4S= jjr0S> r1S? r2S@ r3SA\4\5   S,S4SB jr6 SYSA\
\5\\4\5   4   S0\S,S4SC jjr7SD\SE\S,S4SF jr8SG r9  S[S/SSH.SI\SJ\\   SK\SL\\   4SM jjjr:SD\;S,\<\5   4SN jr=SO\4\4\;      S,\<\5   4SP jr>SQ r?SR r@SS\A4ST jrBSU rCSVrDg)\rU   k   z0Manages communication to and from a Redis server)dbusernameclient_namelib_namelib_versioncredential_providerpasswordsocket_timeoutsocket_connect_timeoutredis_connect_funcretry_on_timeoutretry_on_errorhealth_check_intervalnext_health_checklast_active_atencoderssl_contextprotocol_reader_writer_parser_connect_callbacks_buffer_cutoff_lock_socket_read_size__dict__r   NFutf-8stricti   zredis-pyr   )r_   re   rf   rg   ri   rj   encodingencoding_errorsdecode_responsesparser_classsocket_read_sizerk   ra   rb   rc   r`   retryrh   encoder_classrd   rp   event_dispatcherr_   re   rf   rg   ri   rj   r{   r|   r}   r~   r   rk   ra   rb   rc   r`   r   rh   r   rd   rp   r   c                ~   U(       d  U(       a  Ub  [        S5      eUc  [        5       U l        OUU l        Xl        Xl        Xl        Xl        UU l        X l        UU l	        X0l
        Uc  UnX@l        XPl        U[        L a  / nU(       aS  UR                  [        5        UR                  [         R"                  5        UR                  [$        R                  5        X`l        U(       d  U(       aX  U(       d  [)        [+        5       S5      U l        O[.        R0                  " U5      U l        U R,                  R3                  U5        O[)        [+        5       S5      U l        Xl        SU l        U" XxU	5      U l        UU l        S U l        S U l        Xl         U RC                  U
5        / U l"        SU l#        S U l$        SU l%         [M        U5      nUS:  d  US	:  a  [U        S
5      eUU l+        g ! [N         a	    [P        n N1[R         a    [U        S5      ef = f! WS:  d  US	:  a  [U        S
5      eUU l+        f = f)Nz'username' and 'password' cannot be passed along with 'credential_provider'. Please provide only one of the following arguments: 
1. 'password' and (optional) 'username'
2. 'credential_provider'   r   ip  Fzprotocol must be an integerr   r!   zprotocol must be either 2 or 3),r,   r   _event_dispatcherr_   ra   rb   rc   rd   re   r`   rf   rg   ri   SENTINELappendr/   socketr#   asynciorj   r$   r%   r   copydeepcopyupdate_supported_errorsrk   rl   rn   rh   rq   rr   rw   
set_parserrt   ru   _re_auth_token_should_reconnectint	TypeErrorr&   
ValueErrorr+   rp   )rP   r_   re   rf   rg   ri   rj   r{   r|   r}   r~   r   rk   ra   rb   rc   r`   r   rh   r   rd   rp   r   ps                           rH   __init__AbstractConnection.__init__   s   4 &9&E+  #%4%6D"%5D"& &#6   ,!)%3"&<# 0X%N!!,/!!&..1!!'"6"67,N"9;2
 "]]51
JJ..~>y{A.DJ%:"(*$X@PQ"47;7;!1%NP"8<!&		%HA 1uA%&FGG$DM  	%$A 	A!"?@@	A 1uA%&FGG$DMs$   G2 2HH HH  H<	_warningsc                     [        U SS 5      (       a@  UR                  SU < 3[        U S9   [        R                  " 5         U R                  5         g g ! [         a     g f = f)Nrr   zunclosed Connection )source)getattrwarnResourceWarningr   get_running_loop_closeRuntimeError)rP   r   s     rH   __del__AbstractConnection.__del__   se     4D))NN&th/  ((* *   s   %A 
A! A!c                 x    U R                   (       a)  U R                   R                  5         S=U l         U l        gg)zB
Internal method to silently close the connection without waiting
N)rr   closerq   rP   s    rH   r   AbstractConnection._close   s.     <<LL *..DL4< r<   c                     SR                  S U R                  5        5       5      nSU R                  R                   SU R                  R                   SU S3$ )N,c              3   4   #    U  H  u  pU S U 3v   M     g7f)=Nr@   ).0kvs      rH   	<genexpr>.AbstractConnection.__repr__.<locals>.<genexpr>   s     H5GTQ1QCj5Gs   <.(z)>)joinrepr_pieces	__class__rB   rA   )rP   	repr_argss     rH   __repr__AbstractConnection.__repr__   sQ    HHHT5E5E5GHI	4>>,,-Qt~~/F/F.GqSUVVr<   c                     g rN   r@   r   s    rH   r   AbstractConnection.repr_pieces      r<   c                 H    U R                   S L=(       a    U R                  S L$ rN   )rq   rr   r   s    rH   is_connectedAbstractConnection.is_connected  s    ||4'DDLL,DDr<   c                     [         R                  " U5      nX R                  ;  a  U R                  R                  U5        gg)a.  
Register a callback to be called when the connection is established either
initially or reconnected.  This allows listeners to issue commands that
are ephemeral to the connection, for example pub/sub subscription or
key tracking.  The callback must be a _method_ and will be kept as
a weak reference.
N)weakref
WeakMethodrt   r   )rP   callbackwms      rH   register_connect_callback,AbstractConnection.register_connect_callback	  s9     ),,,##**2. -r<   c                      U R                   R                  [        R                  " U5      5        g! [         a     gf = f)z
De-register a previously registered callback.  It will no-longer receive
notifications on connection events.  Calling this is not required when the
listener goes away, since the callbacks are kept as weak methods.
N)rt   remover   r   r   )rP   r   s     rH   deregister_connect_callback.AbstractConnection.deregister_connect_callback  s8    	##**7+=+=h+GH 		s   /2 
??returnc                 .    U" U R                   S9U l        g)z
Creates a new instance of parser_class with socket size:
_socket_read_size and assigns it to the parser for the connection
:param parser_class: The required parser class
)r   N)rw   rs   )rP   r~   s     rH   r   AbstractConnection.set_parser   s     $T5K5KLr<   c                 >   #    U R                  SS9I Sh  vN   g N7f)z5Connects to the Redis server if not already connectedTcheck_healthN)connect_check_healthr   s    rH   connectAbstractConnection.connect(  s     ''T':::   Tr   retry_socket_connectc                 F  ^ #    T R                   (       a  g  U(       a-  T R                  R                  U 4S jU 4S j5      I S h  vN   OT R                  5       I S h  vN     T R                  (       d  T R                  US9I S h  vN   OO[        R                  " T R                  5      (       a  T R                  T 5      I S h  vN OT R                  T 5        T R$                   Vs/ s H  oU" 5       (       d  M  UPM     snT l        T R$                   HB  nU" 5       nU" T 5      nU(       d  M  [&        R(                  " U5      (       d  M8  UI S h  vN   MD     g  GN GN! [        R
                   a    e [        R                  [        R                  4 a    [        S5      e[         a  n[        T R                  U5      5      eS nAf[         a  n[        U5      UeS nAff = f GNd GN(! [          a    T R#                  5       I S h  vN    e f = fs  snf  N7f)Nc                  $   > T R                  5       $ rN   )_connectr   s   rH   <lambda>9AbstractConnection.connect_check_health.<locals>.<lambda>4  s    DMMOr<   c                 $   > TR                  5       $ rN   
disconnecterrorrP   s    rH   r   r   4  s    4??;Lr<   zTimeout connecting to serverr   )r   r   call_with_retryr   r   CancelledErrorr   r#   r/   OSErrorr+   _error_message	Exceptionrh   on_connect_check_healthiscoroutinefunctionr-   r   rt   inspectisawaitable)rP   r   r   eexcrefr   tasks   `       rH   r   'AbstractConnection.connect_check_health,  s     	0#jj00+-L   mmo%%	**222MMM
 2243J3JKK 11$777006 372I2I"S2I3SU32I"S**CuHD>Dt++D11

	 +E &%% 	 4 45 	?=>> 	:!$"5"5a"899 	0!#&C/	0 N 8  	//###	 #T
 s   H!.E% EE% 
H!E% E"E% #H!%#G2 G,	G2 H!9G2 G/G2 H!+H>H+H!3H!H!H	H!E% "E% %AG)1GG)G$$G))H!,G2 /G2 2HHH	H!c                     SU l         g )NTr   r   s    rH   mark_for_reconnect%AbstractConnection.mark_for_reconnect[  s
    !%r<   c                     U R                   $ rN   r   r   s    rH   should_reconnect#AbstractConnection.should_reconnect^  s    %%%r<   c                    #    g 7frN   r@   r   s    rH   r   AbstractConnection._connecta  s     r\   c                     g rN   r@   r   s    rH   _host_errorAbstractConnection._host_errore  r   r<   	exceptionc                 6    [        U R                  5       U5      $ rN   )r    r   )rP   r   s     rH   r   !AbstractConnection._error_messagei  s    #D$4$4$6	BBr<   c                     U R                   $ rN   )rp   r   s    rH   get_protocolAbstractConnection.get_protocoll  s    }}r<   c                 >   #    U R                  SS9I Sh  vN   g N7f)z=Initialize the connection, authenticate and select a databaseTr   N)r   r   s    rH   
on_connectAbstractConnection.on_connecto  s     ***===r   c                 	  #    U R                   R                  U 5        U R                   nS nU R                  (       d"  U R                  (       d  U R                  (       aK  U R                  =(       d     [        U R                  U R                  5      nUR                  5       I S h  vN nU(       Ga0  U R                  S;  Ga  [        U R                   [        5      (       aK  U R                  [        5        UR                  U R                   l        U R                   R                  U 5        [        U5      S:X  a  SUS   /nU R                  " SU R                  S/UQ7SS06I S h  vN   U R                  5       I S h  vN nUR!                  S	5      [#        U R                  5      :w  a3  UR!                  S
5      [#        U R                  5      :w  a  [%        S5      eGOU(       aR  U R                  " S/UQ7SS06I S h  vN    U R                  5       I S h  vN n[)        U5      S:w  a  [+        S5      eOU R                  S;  a  [        U R                   [        5      (       aK  U R                  [        5        UR                  U R                   l        U R                   R                  U 5        U R                  SU R                  US9I S h  vN   U R                  5       I S h  vN nU R,                  (       aT  U R                  SSU R,                  US9I S h  vN   [)        U R                  5       I S h  vN 5      S:w  a  [%        S5      eU R.                  (       a%  U R                  SSSU R.                  US9I S h  vN   U R0                  (       a%  U R                  SSSU R0                  US9I S h  vN   U R2                  (       a#  U R                  SU R2                  US9I S h  vN   S U R.                  U R0                  4 5        H  n U R                  5       I S h  vN   M     U R2                  (       a1  [)        U R                  5       I S h  vN 5      S:w  a  [%        S5      eg g  GN GN GN GN~ GNh! [&         a:    U R                  SUS   SS9I S h  vN    U R                  5       I S h  vN  n GNf = f GN GN GN GN GNS GN  N N! [4         a     M  f = f N7f)N)r   2r   defaultr   HELLOAUTHr   Fs   protoprotozInvalid RESP versionr   r   OKzInvalid Username or PasswordCLIENTSETNAMEzError setting client nameSETINFOzLIB-NAMEzLIB-VERSELECTc              3   6   #    U  H  o(       d  M  Uv   M     g 7frN   r@   )r   sents     rH   r   =AbstractConnection.on_connect_check_health.<locals>.<genexpr>  s     M#D4$$#Ds   
	zInvalid Database)rs   r   rd   r`   re   r(   get_credentials_asyncrp   
isinstancer7   r   r8   EXCEPTION_CLASSESlensend_commandread_responsegetr   r+   r*   r3   r)   ra   rb   rc   r_   r.   )rP   r   parser	auth_argscred_providerresponseauth_response_s           rH   r   *AbstractConnection.on_connect_check_healths  s\    %	##(( T5dmmT]]S  ,AACCI h6$,,(9:: 12171I1I.''-9~"&	!5	 ##1:IN   "//11H||H%T]]);;AT]]#A$ &&<== ##FKYKUKKK;&*&8&8&: : M*d2)*HII 3 ]](*$,,(9:: 12171I1I.''-##GT]]#VVV!//11H ##  )	 $    $"4"4"6674?%&ABB ==##) $    ##  ) $    77##HdggL#QQQ NDMM43C3C#DMA((*** N 77$"4"4"6674?%&899 @ { D 2 L !;7 ;
 ''	"E'RRR&*&8&8&: : :;$ W1 7
 R
 +   7sT  B#S6%Q7&CS6(Q:)S6 Q=BS6R S6R RR  B3S6SS6+S,4S6 S!S6=S>AS6S5S6<S=3S60S1&S6S#+S!,S#0-S6S4S6:S6=S6 S6R !S
'R*(S
 SS
S6	S

S6S6S6S6S6S6S6!S##
S1-S60S11S6nowaitc                 t  #     [        U R                  5       ISh  vN   U R                  R                  5         U R                  (       d   SSS5      ISh  vN   g U R
                  R                  5         U(       d"  U R
                  R                  5       I Sh  vN   SU l	        SU l        SSS5      ISh  vN   g N Nj N'! [         a     N1f = f! SU l	        SU l        f = f N.! , ISh  vN  (       d  f       g= f! [        R                   a    [        SU R                   35      Sef = f7f)z!Disconnects from the Redis serverNz#Timed out closing connection after )async_timeoutrg   rs   on_disconnectr   rr   r   wait_closedr   rq   r   r/   )rP   r  s     rH   r   AbstractConnection.disconnect  s     	$T%@%@AA**,(( BAA
(LL&&( ""ll66888 $(DL#'DL BAA 9  $(DL#'DL BAAA ## 	5d6Q6Q5RS	s   D8D CD -C-D CD D8 >CCC#C-1D <C+=D D8D D C
CCCCC((C-+D -D3C64D D D8D .D55D8c                    #    U R                  SSS9I Sh  vN   [        U R                  5       I Sh  vN 5      S:w  a  [        S5      eg N5 N7f)z Send PING, expect PONG in returnPINGFr   NPONGz#Bad response from PING health check)r  r3   r  r+   r   s    rH   
_send_pingAbstractConnection._send_ping  sP     U;;;d00223v=!"GHH > 	<2s   AAAAAAc                 @   #    U R                  5       I Sh  vN   g N7f)z Function to call when PING failsNr   rP   r   s     rH   _ping_failedAbstractConnection._ping_failed       oo   c                   #    U R                   (       ak  [        R                  " 5       R                  5       U R                  :  a9  U R
                  R                  U R                  U R                  5      I Sh  vN   ggg N7f)z3Check the health of the connection with a PING/PONGN)	rk   r   r   timerl   r   r   r&  r*  r   s    rH   r   AbstractConnection.check_health   se      &&((*//1D4J4JJ**,,T__d>O>OPPP K ' Qs   A6B8B 9Bcommandc                    #    U R                   R                  U5        U R                   R                  5       I S h  vN   g  N7frN   )rr   
writelinesdrain)rP   r1  s     rH   _send_packed_command'AbstractConnection._send_packed_command  s-     (ll  """s   9AAAc                   #    U R                   (       d  U R                  SS9I S h  vN   U(       a  U R                  5       I S h  vN    [        U[        5      (       a  UR                  5       n[        U[        5      (       a  U/nU R                  (       a9  [        R                  " U R                  U5      U R                  5      I S h  vN   g U R                  R                  U5        U R                  R                  5       I S h  vN   g  N N NG N! [        R                   a%    U R                  SS9I S h  vN    [        S5      S e[          ax  nU R                  SS9I S h  vN    [#        UR$                  5      S:X  a  SUR$                  S   pTOUR$                  S   nUR$                  S   n['        S	U S
U S35      UeS nAf[(         a    U R                  SS9I S h  vN    e f = f7f)NFr   Tr  zTimeout writing to socketr   UNKNOWNr   zError z while writing to socket. r   )r   r   r   r  strencodebytesrf   r   wait_forr5  rr   r3  r4  r/   r   r   r  argsr+   BaseException)rP   r1  r   r   err_noerrmsgs         rH   send_packed_command&AbstractConnection.send_packed_command  s       +++???##%%%	'3''!..*'5))")""&&--g68K8K   ''0ll((*** @%
 +## 	F///...:;E 		///...166{a!*AFF1I! :6(!D  	
 ///...	s   $G6DG6DG6BD DD G68D 
DD G6G6D D &G3>E?G3G+E.,A GG3+G.,G33G6r>  kwargsc                 z   #    U R                  U R                  " U6 UR                  SS5      S9I Sh  vN   g N7f)z+Pack and send a command to the Redis serverr   Tr   N)rB  pack_commandr  )rP   r>  rD  s      rH   r  AbstractConnection.send_command5  s=     &&t$6::nd3S ' 
 	
 	
s   1;9;c                    #     U R                   R                  5       I Sh  vN $  N! [         aH  nU R                  SS9I Sh  vN    U R	                  5       n[        SU SUR                   35      eSnAff = f7f)z8Poll the socket to see if there's data that can be read.NTr8  Error while reading from z: )rs   can_read_destructiver   r   r   r+   r>  )rP   r   
host_errors      rH   rJ  'AbstractConnection.can_read_destructive;  st     	V::<<<< 	V///...))+J!$=j\AFF8"TUU	Vs<   A=( &( A=( 
A:A5A0A55A::A=)disconnect_on_errorpush_requestdisable_decodingr#   rM  rN  c                   #    Ub  UOU R                   nU R                  5       n UbV  U R                  S;   aF  [        U5       ISh  vN   U R                  R                  XS9I Sh  vN nSSS5      ISh  vN   OUbF  [        U5       ISh  vN   U R                  R                  US9I Sh  vN nSSS5      ISh  vN   OTU R                  S;   a"  U R                  R                  XS9I Sh  vN nO"U R                  R                  US9I Sh  vN n U R                  (       a6  [        R                  " 5       R                  5       U R                  -   n	Xl        [#        W[$        5      (       a  USeU$  GN5 GN GN
! , ISh  vN  (       d  f       N= f GN N N! , ISh  vN  (       d  f       N= f N N! [        R                   a3    Ub   gU(       a  U R                  SS9I Sh  vN    [        SU 35      e[         a?  nU(       a  U R                  SS9I Sh  vN    [        SU S	UR                   35      eSnAf[         a!    U(       a  U R                  SS9I Sh  vN    e f = f7f)
z0Read the response from a previously sent commandN)3r!   )rO  rN  )rO  Tr8  zTimeout reading from rI  z : )rf   r   rp   r  rs   r  r   r/   r   r   r+   r>  r?  rk   r   r/  rl   r  r.   )
rP   rO  r#   rM  rN  read_timeoutrK  r  r   	next_times
             rH   r   AbstractConnection.read_responseD  s=     #*"5w4;N;N%%'
%	'DMMX,E(66%)\\%?%?)9 &@ &  H 766 )(66%)\\%?%?)9 &@ &  H 766 (*!%!;!;%5 "< "  "&!;!;%5 "< " . %%002779D<V<VVI%."h..$W 7  7666
 7  7666
 ## 	E""ooTo222!6zlCDD 	W"ooTo222!$=j\QVVH"UVV 	 #ooTo222	sa  "I>"G E<G F(E?)F-G 8F9G =I>>G FG F&1F"2F&6G F$G I>,G 3G 4G 8I>9G GG A"I><G ?FG FFFG I>G "F&$G &F=,F/-F=9G <I>=G G I;I>I;6G97I;I,H/- I&I;3I64I;;I>c           	         / n[        US   [        5      (       a   e[        US   [        5      (       a1  [        US   R	                  5       R                  5       5      USS -   nO+SUS   ;   a"  [        US   R                  5       5      USS -   n[        R                  [        [        [        U5      5      R	                  5       [        45      nU R                  n[        U R                  R                  U5       H  n[        U5      n[        U5      U:  d  Xd:  d  [        U[        5      (       ab  [        R                  U[        [        U5      R	                  5       [        45      nUR!                  U5        UR!                  U5        [        nM  [        R                  U[        [        U5      R	                  5       [        U[        45      nM     UR!                  U5        U$ )z2Pack a series of arguments into the Redis protocolr   r   N    )r  floatr:  tupler;  split	SYM_EMPTYr   SYM_STARr  SYM_CRLFru   maprn   
memoryview
SYM_DOLLARr   )rP   r>  outputbuffbuffer_cutoffarg
arg_lengths          rH   rF  AbstractConnection.pack_command~  s    d1gu----d1gs##a)//12T!"X=DT!W_a)DH4D~~xSY)>)>)@(KL++t||**D1C SJD	M)-c:.. ~~:s:'='='?J d#c" ~~"J..0  	! 24 	dr<   commandsc                    / n/ nSnU R                   nU H  nU R                  " U6  H  n[        U5      nXE:  d  X:  d  [        U[        5      (       a/  U(       a$  UR                  [        R                  U5      5        Sn/ nX:  d  [        U[        5      (       a  UR                  U5        M  UR                  U5        XH-  nM     M     U(       a$  UR                  [        R                  U5      5        U$ )z.Pack multiple commands into the Redis protocolr   )ru   rF  r  r  r^  r   rZ  r   )	rP   rf  r`  piecesbuffer_lengthrb  cmdchunkchunklens	            rH   pack_commands AbstractConnection.pack_commands  s      ++C**C0u:!1/!%44innV&<=$%MF+z%/L/LMM%(MM%(!-M! 1 & MM)..01r<   c                 F    [        U R                  R                  5      S:H  $ )zCheck if the socket is emptyr   )r  rq   _bufferr   s    rH   _socket_is_empty#AbstractConnection._socket_is_empty  s    4<<''(A--r<   c                    #    U R                  5       (       d/  U R                  SS9I S h  vN   U R                  5       (       d  M.  g g  N7f)NT)rN  )rq  r  r   s    rH   process_invalidation_messages0AbstractConnection.process_invalidation_messages  s?     ''))$$$$777 ''))7s   (A
AA
A
tokenc                     Xl         g rN   )r   )rP   rv  s     rH   set_re_auth_token$AbstractConnection.set_re_auth_token  s    #r<   c                   #    U R                   bl  U R                  SU R                   R                  S5      U R                   R                  5       5      I S h  vN   U R	                  5       I S h  vN   S U l         g g  N% N7fNr  oid)r   r  try_get	get_valuer  r   s    rH   re_authAbstractConnection.re_auth  s}     *####++E2##--/  
 $$&&&"&D +
 's$   ABA=B/A?0B?B)ru   rt   r   rs   r   rq   r   rw   rr   ra   rd   r_   rn   rk   rb   rc   rl   re   rp   rh   r   rj   ri   rg   rf   r`   )TTr   NT)F)FN)ErA   rB   rC   rD   __doc__	__slots__r   rI   r2   r5   r   r:  r   r   rW  boollistr>   r   r4   r$   ConnectCallbackTr'   r   r   warningsr   r   r   r   r   r   propertyr   r   r   r   r   r   r   r   r   r   r?  r   r   r   r   r   r&  r*  r   r   r<  r5  rB  r  rJ  r  r0   r	   rF  rm  rq  rt  r   rx  r  rG   r@   r<   rH   rU   rU   k   s   :I@  "&*.26!&19'!&)6 %'(%)",%4%6"&!%9='.<@"#6:1X% #s(OX% 3-	X%
 !X% !)X% X% dIo.X% X% X% X% :&X% X%  %X% c]X%  3-!X%" c]#X%$ 3-%X%& 'X%( %%56)X%* G}+X%, &&89-X%. 3-/X%0 #?31X%t (0   /W   E E
/	MtJ'7 MD M;
 GK- -?C-^&&   S  C C# C>j:$ j:$ j:Xt  .I Q#(5/ #d #
 QU'UC%89'IM'	'R
 
s 
t 
V "'#'8
 %)',88 %8
 "8 tn8t,* ,e ,\hx
/C&D e <.8$~ $'r<   rU   c                      ^  \ rS rSrSrSSSSSS.S	\S
\\\4   S\S\	\
\\\\4   4      S\4
U 4S jjjrS rS\
4S jrS rS\4S jrSrU =r$ )
Connectioni  z4Manages TCP communication to and from a Redis server	localhosti  FNr   )hostportsocket_keepalivesocket_keepalive_optionssocket_typer  r  r  r  r  c                   > Xl         [        U5      U l        X0l        U=(       d    0 U l        XPl        [        TU ]  " S0 UD6  g Nr@   )r  r   r  r  r  r  superr   )rP   r  r  r  r  r  rD  r   s          rH   r   Connection.__init__  s>     	I	 0(@(FB%&"6"r<   c                     SU R                   4SU R                  4SU R                  4/nU R                  (       a  UR	                  SU R                  45        U$ )Nr  r  r_   ra   )r  r  r_   ra   r   rP   rh  s     rH   r   Connection.repr_pieces  sM    499%		':T477OLMM=$*:*:;<r<   r   c                 4    U R                   U R                  S.$ )Nr  r  r  r   s    rH   _connection_arguments Connection._connection_arguments  s    		49955r<   c                   #    [        U R                  5       ISh  vN   [        R                  " S0 U R	                  5       D6I Sh  vN u  pSSS5      ISh  vN   WU l        WU l        UR                  R                  S5      nU(       a  UR                  [        R                  [        R                  S5         U R                  (       as  UR                  [        R                  [        R                  S5        U R                   R#                  5        H%  u  pEUR                  [        R$                  XE5        M'     ggg GN) N N! , ISh  vN  (       d  f       GN= f! [&        [(        4 a    UR+                  5         e f = f7f)zCreate a TCP socket connectionNr   r   r@   )r  rg   r   open_connectionr  rq   rr   	transportget_extra_info
setsockoptr   IPPROTO_TCPTCP_NODELAYr  
SOL_SOCKETSO_KEEPALIVEr  itemsSOL_TCPr   r   r   )rP   readerwritersockr   r   s         rH   r   Connection._connect  s(     !<!<==#*#:#: $,,.$ NF >= ..x8OOF..0B0BAF((OOF$5$5v7J7JAN $ = = C C E= !F )	  > >===  Y'  	sp   FEF(EE	EFE
A#F?BE' FE
FE$EE$F'"F		Fc                 8    U R                    SU R                   3$ )N:r  r   s    rH   r   Connection._host_error  s    ))Adii[))r<   )rq   rr   r  r  r  r  r  )rA   rB   rC   rD   r  r:  r   r   r  r   r
   r<  r   r   r  r   r   rG   __classcell__r   s   @rH   r  r    s    :
   $!&NR# # CHo	#
 # #+73c5j8I3I+J"K# # #"6w 60*S * *r<   r  c                   n  ^  \ rS rSrSr          SS\\   S\\   S\\\R                  4   S\\
S      S\\
S      S	\\   S
\\   S\S\\   S\\   4U 4S jjjrS\4U 4S jjr\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       rSrU =r$ )SSLConnectioni  zManages SSL connections to and from the Redis server(s).
This class extends the Connection class, adding SSL functionality, and making
use of ssl.SSLContext (https://docs.python.org/3/library/ssl.html#ssl.SSLContext)
ssl_keyfilessl_certfilessl_cert_reqsssl_include_verify_flagsssl.VerifyFlagsssl_exclude_verify_flagsssl_ca_certsssl_ca_datassl_check_hostnamessl_min_versionssl_ciphersc                    > [         (       d  [        S5      e[        UUUUUUUUU	U
S9
U l        [        TU ]  " S0 UD6  g )N$Python wasn't built with SSL support)
keyfilecertfile	cert_reqsinclude_verify_flagsexclude_verify_flagsca_certsca_datacheck_hostnamemin_versionciphersr@   )r   r-   RedisSSLContextro   r  r   )rP   r  r  r  r  r  r  r  r  r  r  rD  r   s               rH   r   SSLConnection.__init__  sS     }CDD,;!#!9!9!-'-
 	"6"r<   r   c                 ^   > [         TU ]  5       nU R                  R                  5       US'   U$ )Nssl)r  r  ro   r  )rP   rD  r   s     rH   r  #SSLConnection._connection_arguments>  s-    .0((,,.ur<   c                 .    U R                   R                  $ rN   )ro   r  r   s    rH   r  SSLConnection.keyfileC      '''r<   c                 .    U R                   R                  $ rN   )ro   r  r   s    rH   r  SSLConnection.certfileG      (((r<   c                 .    U R                   R                  $ rN   )ro   r  r   s    rH   r  SSLConnection.cert_reqsK  s    )))r<   c                 .    U R                   R                  $ rN   )ro   r  r   s    rH   r  "SSLConnection.include_verify_flagsO      444r<   c                 .    U R                   R                  $ rN   )ro   r  r   s    rH   r  "SSLConnection.exclude_verify_flagsS  r  r<   c                 .    U R                   R                  $ rN   )ro   r  r   s    rH   r  SSLConnection.ca_certsW  r  r<   c                 .    U R                   R                  $ rN   )ro   r  r   s    rH   r  SSLConnection.ca_data[  r  r<   c                 .    U R                   R                  $ rN   )ro   r  r   s    rH   r  SSLConnection.check_hostname_  s    ...r<   c                 .    U R                   R                  $ rN   )ro   r  r   s    rH   r  SSLConnection.min_versionc  s    +++r<   )ro   )
NNrequiredNNNNTNN)rA   rB   rC   rD   r  r   r:  r   r  
VerifyModer	   r  r   r   r
   r  r  r  r  r  r  r  r  r  r  r  rG   r  r  s   @rH   r  r    s    &*&*4>FJFJ&*%)#'04%)#c]# sm# S#..01	#
 #+40A+B"C# #+40A+B"C# sm# c]# !# "*-# c]# #>w 
 ( ( ) ) * * 5 5 5 5 ) ) ( ( / / , ,r<   r  c                       \ rS rSrSr          SS\\   S\\   S\\\\R                  4      S\\
S      S	\\
S      S
\\   S\\   S\S\\   S\\   4S jjrS\4S jrSrg)r  ih  )r  r  r  r  r  r  r  contextr  r  r  Nr  r  r  r  r  r  r  r  r  r  r  c                    [         (       d  [        S5      eXl        X l        Uc  [        R
                  nO\[        U[        5      (       aG  [        R
                  [        R                  [        R                  S.nX;;  a  [        SU 35      eX   nX0l
        X@l        XPl        X`l        Xpl        U R                  [        R
                  :w  a  UOSU l        Xl        Xl        S U l        g )Nr  )noneoptionalr  z+Invalid SSL Certificate Requirements Flag: F)r   r-   r  r  r  	CERT_NONEr  r:  CERT_OPTIONALCERT_REQUIREDr  r  r  r  r  r  r  r  r  )rP   r  r  r  r  r  r  r  r  r  r  	CERT_REQSs               rH   r   RedisSSLContext.__init__w  s     }CDD I	3''----I
 ) A)M  ",I"$8!$8! "nn=N5 	 '-1r<   r   c                 B   U R                   (       Gd  [        R                  " 5       nU R                  Ul        U R                  Ul        U R                  (       a(  U R                   H  nU=R                  U-  sl        M     U R                  (       a)  U R                   H  nU=R                  U) -  sl        M     U R                  (       a5  U R                  (       a$  UR                  U R                  U R                  S9  U R                  (       d  U R                  (       a$  UR                  U R                  U R                  S9  U R                  b  U R                  Ul        U R"                  b  UR%                  U R"                  5        Xl         U R                   $ )N)r  r  )cafilecadata)r  r  create_default_contextr  r  verify_moder  verify_flagsr  r  r  load_cert_chainr  r  load_verify_locationsr  minimum_versionr  set_ciphers)rP   r  flags      rH   r  RedisSSLContext.get  s   |||002G%)%8%8G""&..G(( 55D((D0( 6(( 55D((TE1( 6}}'''U}}--T]]4<<-X+*.*:*:'||'##DLL1"L||r<   )r  r  r  r  r  r  r  r  r  r  r  )
NNNNNNNFNN)rA   rB   rC   rD   r  r   r:  r   r  r  r	   r  r   r   r   r  rG   r@   r<   rH   r  r  h  s    I  "&"&:>BFBF"&!%$,0!%)2#)2 3-)2 E#s~~"567	)2
 't,='>?)2 't,='>?)2 3-)2 #)2 )2 j))2 #)2VZ r<   r  c                   x   ^  \ rS rSrSrSS.S\4U 4S jjjrS\\\\	\\
4   4      4S jrS	 rS\4S
 jrSrU =r$ )UnixDomainSocketConnectioni  z4Manages UDS communication to and from a Redis server pathr   c                2   > Xl         [        TU ]  " S0 UD6  g r  )r   r  r   )rP   r   rD  r   s      rH   r   #UnixDomainSocketConnection.__init__  s    	"6"r<   r   c                     SU R                   4SU R                  4/nU R                  (       a  UR                  SU R                  45        U$ )Nr   r_   ra   )r   r_   ra   r   r  s     rH   r   &UnixDomainSocketConnection.repr_pieces  sB    499%dgg7MM=$*:*:;<r<   c                 H  #    [        U R                  5       IS h  vN   [        R                  " U R                  S9I S h  vN u  pS S S 5      IS h  vN   WU l        WU l        U R                  5       I S h  vN   g  Nc N? N/! , IS h  vN  (       d  f       ND= f N%7f)Nr  )r  rg   r   open_unix_connectionr   rq   rr   r   )rP   r  r  s      rH   r   #UnixDomainSocketConnection._connect  sq      !<!<==#*#?#?TYY#OONF >=oo	 >O >=== 	 sb   B"B B""BBB	B"B%B":B ;B"BB"BBBB"c                     U R                   $ rN   r  r   s    rH   r   &UnixDomainSocketConnection._host_error  s    yyr<   )rq   rr   r   )rA   rB   rC   rD   r  r:  r   r   r   r   r   r   r   r   rG   r  r  s   @rH   r  r    sS    :&( # # #XeCsCx,@&AB  S  r<   r  )0FFALSENNOr   c                     U b  U S:X  a  g [        U [        5      (       a  U R                  5       [        ;   a  g[	        U 5      $ )Nr  F)r  r:  upperFALSE_STRINGSr  )values    rH   to_boolr    s7    }%%++-="@;r<   c                 "   U R                  SS5      R                  SS5      n/ nUR                  S5       HU  nUR                  5       n[        [        U5      (       d  [        SU 35      eUR                  [        [        U5      5        MW     U$ )N[r  ]r   zInvalid ssl verify flag: )replacerY  striphasattrr   r   r   r   )r  verify_flags_strr  r  s       rH   parse_ssl_verify_flagsr    s     }}S"-55c2>L &&s+zz|{D))8?@@GK67	 ,
 r<   )r_   rf   rg   r  ri   max_connectionsrk   r  r  r  r#   .URL_QUERY_ARGUMENT_PARSERSc                   b    \ rS rSr% \\S'   \\S'   \\   \S'   \\S'   \\S'   \\S'   \\S'   S	r	g
)ConnectKwargsi  r`   re   connection_classr  r  r_   r   r@   N)
rA   rB   rC   rD   r:  __annotations__r   rU   r   rG   r@   r<   rH   r  r    s,    MM-..
I
IG
Ir<   r  F)totalurlc                 j   [        U 5      n0 n[        UR                  5      R                  5        HZ  u  p4U(       d  M  [	        U5      S:  d  M  [        US   5      n[        R                  U5      nU(       a   U" U5      X#'   MV  XRU'   M\     UR                  (       a  [        UR                  5      US'   UR                  (       a  [        UR                  5      US'   UR                  S:X  a4  UR                  (       a  [        UR                  5      US'   [        US'   U$ UR                  S	;   a  UR                  (       a  [        UR                  5      US
'   UR                   (       a  [#        UR                   5      US'   UR                  (       a8  SU;  a2   [#        [        UR                  5      R%                  SS5      5      US'   UR                  S:X  a	  [(        US'   U$ Sn[        SU S35      e! [        [        4 a    [        SU S35      ef = f! [&        [        4 a     Naf = f)Nr   zInvalid value for 'z' in connection URL.r`   re   unixr   r   )redisredissr  r  r_   /r  r'  zredis://, rediss://, unix://z5Redis URL must specify one of the following schemes ())r   r   queryr  r  r   r  r  r   r   r`   re   schemer   r  hostnamer  r   r  AttributeErrorr  )r#  parsedrD  name
value_listr  r  valid_schemess           rH   	parse_urlr2    s   "3-FF$V\\288::#j/A-JqM*E/33D9FW#)%=FL  %t ; $V__5z$V__5z }};;$V[[1F6N%?!"2 M/ 
-	-??$V__5F6N;; -F6N ;;4v-"76;;#7#?#?R#HIt ==H$)6F%& M 7CM?RST
 	
G ":. W$':4&@T%UVVW6 #J/ s   ;
G<1H < HH21H2_CPConnectionPool)boundc                      \ rS rSrSr\S\\   S\S\4S j5       r	\
S4S\\   S	\\   4S
 jjrS rS rS\4S jr\" S/SSS9S#S j5       rS rS rS rS\4S jrS\4S jrS$S\4S jjrS rS%S jrS&S jrS\4S jrS \ 4S! jr!S"r"g)'r4  i=  a  
Create a connection pool. ``If max_connections`` is set, then this
object raises :py:class:`~redis.ConnectionError` when the pool's
limit is reached.

By default, TCP connections are created unless ``connection_class``
is specified. Use :py:class:`~redis.UnixDomainSocketConnection` for
unix sockets.
:py:class:`~redis.SSLConnection` can be used for SSL enabled connections.

Any additional keyword arguments are passed to the constructor of
``connection_class``.
clsr#  r   c                 J    [        U5      nUR                  U5        U " S0 UD6$ )a'  
Return a connection pool 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.
r@   )r2  update)r7  r#  rD  url_optionss       rH   from_urlConnectionPool.from_urlL  s&    V  nk"}V}r<   Nr   r  c                    U=(       d    Sn[        U[        5      (       a  US:  a  [        S5      eXl        X0l        X l        / U l        [        5       U l        U R                  R                  S[        5      U l        [        R                  " 5       U l        U R                  R                  SS 5      U l        U R                  c  [!        5       U l        g g )Nl        r   z,"max_connections" must be a positive integerr   r   )r  r   r   r   connection_kwargsr  _available_connectionsset_in_use_connectionsr  r5   r   r   Lockrv   r   r   )rP   r   r  r>  s       rH   r   ConnectionPool.__init__{  s     *2U/3//?Q3FKLL 0!2.@B#<?E !3377Q\\^
!%!7!7!;!;<NPT!U!!)%4%6D" *r<   c                 X   SR                  U R                  R                  5        VVs/ s H  u  pU SU 3PM     snn5      nSU R                  R                   SU R                  R
                   SU R                  R                   SU R                  R
                   SU S3$ s  snnf )Nr   r   r   r   z(<r   z)>)>)r   r>  r  r   rB   rA   r   )rP   r   r   conn_kwargss       rH   r   ConnectionPool.__repr__  s    hht7M7M7S7S7UV7Utq1#Qqc
7UVW))*!DNN,C,C+D&&112!D4I4I4R4R3S}D"	
  Ws   B&
c                 F    / U l         [        R                  " 5       U l        g rN   )r?  r   WeakSetrA  r   s    rH   resetConnectionPool.reset  s    &(##*??#4 r<   c                 l    U R                   =(       d"    [        U R                  5      U R                  :  $ )z;Return True if a connection can be retrieved from the pool.)r?  r  rA  r  r   s    rH   can_get_connection!ConnectionPool.can_get_connection  s1     '' D4++,t/C/CC	
r<   *)Use get_connection() without args instead5.3.0args_to_warnreasonversionc                 B  #    U R                    IS h  vN    U R                  5       n U R                  U5      I S h  vN   S S S 5      IS h  vN   U$  NA N! [         a    U R	                  U5      I S h  vN    e f = f N3! , IS h  vN  (       d  f       W$ = f7frN   )rv   get_available_connectionensure_connectionr?  release)rP   command_namekeysoptionsrQ   s        rH   get_connectionConnectionPool.get_connection  s      ::::668J,,Z888	 :   9  ll:... :: sq   BABBAAABBBAA?7A:8A??BBB
BBBc                     U R                   R                  5       nU R                  R                  U5        U$ ! [         aB    [        U R                  5      U R
                  :  a  [        S5      SeU R                  5       n Nhf = f)zCGet a connection from the pool, without making sure it is connectedzToo many connectionsN)	r?  pop
IndexErrorr  rA  r  r+   make_connectionaddrO   s     rH   rV  'ConnectionPool.get_available_connection  s}    	04488:J
 	  $$Z0  	04++,0D0DD%&<=4G--/J	0s   9 A	BBc                     U R                   nU R                  UR                  SS5      UR                  SS5      UR                  SS5      S9$ )z,Return an encoder based on encoding settingsr{   ry   r|   rz   r}   F)r{   r|   r}   )r>  r   r  )rP   rD  s     rH   get_encoderConnectionPool.get_encoder  sQ    ''!!ZZ
G4"JJ'8(C#ZZ(:EB " 
 	
r<   c                 :    U R                   " S0 U R                  D6$ )z=Create a new connection.  Can be overridden by child classes.r@   )r   r>  r   s    rH   ra  ConnectionPool.make_connection  s    $$>t'='=>>r<   rQ   c                   #    UR                  5       I Sh  vN    UR                  5       I Sh  vN (       a  [        S5      Seg N/ N! [        [        [        4 a_    UR                  5       I Sh  vN    UR                  5       I Sh  vN    UR                  5       I Sh  vN  (       a  [        S5      Se gf = f7f)z8Ensure that the connection object is connected and validNzConnection has datazConnection not ready)r   rJ  r+   r/   r   r   rO   s     rH   rW   ConnectionPool.ensure_connection  s       """
	H44666%&;<$F 7 	# 7w7 	H'')))$$&&&44666%&<=4G 7	Hsf   CACA
 AA
 CA
 
(B>2A53B>BB>$B'%B>;C=B>>Cc                 2  #    U R                   R                  U5        UR                  5       (       a  UR                  5       I Sh  vN   U R                  R                  U5        U R                  R                  [        U5      5      I Sh  vN   g NL N7f)z(Releases the connection back to the poolN)	rA  r   r   r   r?  r   r   dispatch_asyncr   rO   s     rH   rX  ConnectionPool.release  s      	  ''
3&&(('')))##**:6$$33-j9
 	
 	
 *	
s%   ABBABBBBinuse_connectionsc                    #    U(       a!  [        U R                  U R                  5      nOU R                  n[        R                  " S U 5       SS06I Sh  vN n[        S U 5       S5      nU(       a  Ueg N!7f)z
Disconnects connections in the pool

If ``inuse_connections`` is True, disconnect connections that are
current in use, potentially by other tasks. Otherwise only disconnect
connections that are idle in the pool.
c              3   @   #    U  H  oR                  5       v   M     g 7frN   r   )r   rQ   s     rH   r   ,ConnectionPool.disconnect.<locals>.<genexpr>  s     D*##%%s   return_exceptionsTNc              3   T   #    U  H  n[        U[        5      (       d  M  Uv   M      g 7frN   )r  r?  )r   rs     rH   r   rq    s     Dt!z!]'CAAts   (	()r   r?  rA  r   gathernext)rP   rn  connectionsrespr   s        rH   r   ConnectionPool.disconnect  s{      8=++T-E-E9K 55K^^DD
"
 
 DtDdKI 
s   AA;A9"A;c                    #    U R                    ISh  vN   U R                   H  nUR                  5         M     SSS5      ISh  vN   g N8 N! , ISh  vN  (       d  f       g= f7f)z,
Mark all active connections for reconnect.
N)rv   rA  r   )rP   conns     rH   'update_active_connections_for_reconnect6ConnectionPool.update_active_connections_for_reconnect   s;      :::00'') 1 :::::sC   A*AA*$AA*AA*A*A'AA'#A*c                 @   #    U R                  5       I Sh  vN   g N7f)z-Close the pool, disconnecting all connectionsNr   r   s    rH   acloseConnectionPool.aclose  r,  r-  c                 h    U R                    H	  nXl        M     U R                   H	  nXl        M     g rN   )r?  r   rA  )rP   r   r{  s      rH   	set_retryConnectionPool.set_retry  s,    //DJ 0,,DJ -r<   rv  c                   ^ ^^#    T R                    IS h  vN   T R                   H\  mTR                  R                  UU4S jU 4S j5      I S h  vN   TR                  R                  U4S jU 4S j5      I S h  vN   M^     T R                   H  mTR                  T5        M     S S S 5      IS h  vN   g  N Nk NA N! , IS h  vN  (       d  f       g = f7f)Nc                  d   > T R                  STR                  S5      TR                  5       5      $ r{  )r  r}  r~  )r{  rv  s   rH   r   1ConnectionPool.re_auth_callback.<locals>.<lambda>  s'    D--e 4eoo6Gr<   c                 &   > TR                  U 5      $ rN   _mockr   s    rH   r   r    s    $**U"3r<   c                  $   > T R                  5       $ rN   )r  )r{  s   rH   r   r    s    D..0r<   c                 &   > TR                  U 5      $ rN   r  r   s    rH   r   r    s    

5@Qr<   )rv   r?  r   r   rA  rx  )rP   rv  r{  s   ``@rH   re_auth_callbackConnectionPool.re_auth_callback  s     :::33jj00 4	   jj0002Q   4 00&&u- 1 :: :::sh   CB<C8CB>+C>C ?,C+C6C7C>C CCC
CCCr   c                    #    g7f)z_
Dummy functions, needs to be passed as error callback to retry object.
:param error:
:return:
Nr@   r)  s     rH   r  ConnectionPool._mock!  s
      	r\   )r?  r   rA  rv   r   r>  r   r  rN   r  r  )r   r$   r   N)#rA   rB   rC   rD   r  classmethodr   r3  r:  r;  r  rU   r   r   r   r   rI  r  rL  r   r\  rV  re  ra  rW  rX  r   r|  r  r  r   r  r-   r  rG   r@   r<   rH   r4  r4  =  s     ,d3i ,c , , ,` 6@)-7127 "#7,
5
D 
 U:



	
?H2D H 
(: 
$ ,* .N . r<   c            
          ^  \ rS rSrSrSS\\R                  4S\S\	\
   S\\   S\\R                     4U 4S	 jjjr\" S
/SSS9SU 4S jj5       rS\4U 4S jjrSrU =r$ )BlockingConnectionPooli*  a  
A blocking connection pool::

    >>> from redis.asyncio import Redis, BlockingConnectionPool
    >>> client = Redis.from_pool(BlockingConnectionPool())

It performs the same function as the default
:py:class:`~redis.asyncio.ConnectionPool` implementation, in that,
it maintains a pool of reusable connections that can be shared by
multiple async redis clients.

The difference is that, in the event that a client tries to get a
connection from the pool when all of connections are in use, rather than
raising a :py:class:`~redis.ConnectionError` (as the default
:py:class:`~redis.asyncio.ConnectionPool` implementation does), it
blocks the current `Task` for a specified number of seconds until
a connection becomes available.

Use ``max_connections`` to increase / decrease the pool size::

    >>> pool = BlockingConnectionPool(max_connections=10)

Use ``timeout`` to tell it either how many seconds to wait for a connection
to become available, or to block forever:

    >>> # Block forever.
    >>> pool = BlockingConnectionPool(timeout=None)

    >>> # Raise a ``ConnectionError`` after five seconds if a connection is
    >>> # not available.
    >>> pool = BlockingConnectionPool(timeout=5)
2      r  r#   r   queue_classc                 l   > [         TU ]  " SUUS.UD6  [        R                  " 5       U l        X l        g )N)r   r  r@   )r  r   r   	Condition
_conditionr#   )rP   r  r#   r   r  r>  r   s         rH   r   BlockingConnectionPool.__init__L  s>     	 	
-+	
  	

 "++-r<   rN  rO  rP  rQ  c                   >#     U R                    ISh  vN   [        U R                  5       ISh  vN   U R                   R                  U R                  5      I Sh  vN   [
        TU ]  5       nSSS5      ISh  vN   SSS5      ISh  vN    U R                  W5      I Sh  vN   U$  N N} NR N6! , ISh  vN  (       d  f       NK= f NB! , ISh  vN  (       d  f       NW= f! [        R                   a  n[        S5      UeSnAff = f Nl! [         a    U R                  W5      I Sh  vN    e f = f7f)z@Gets a connection from the pool, blocking until one is availableNzNo connection available.)r  r  r#   r=  rL  r  rV  r   r/   r+   rW  r?  rX  )rP   rY  rZ  r[  rQ   errr   s         rH   r\  %BlockingConnectionPool.get_connection\  s     	G(66//2243J3JKKK!&!A!CJ 76 '	((444 '6K 7666 ' ## 	G!"<=3F	G
 5 	,,z***	s   E C- B/C- CB1C)B7 B3!B73C>B5?CC- CC- D (D)D .E /C- 1C3B75C7C	=C >C	
CC- C*CC*&C- )E *C- -DDDE D D=5D86D==E rQ   c                    >#    U R                    ISh  vN   [        TU ]	  U5      I Sh  vN   U R                   R                  5         SSS5      ISh  vN   g NF N1 N	! , ISh  vN  (       d  f       g= f7f)z)Releases the connection back to the pool.N)r  r  rX  notify)rP   rQ   r   s     rH   rX  BlockingConnectionPool.releases  sH     ???'/*---OO""$ #??- #???sT   A;AA;A!AA!
A;AA;A!A;!A8'A*(A84A;)r  r#   rN   )rA   rB   rC   rD   r  r  r   	LifoQueuer   r   rW  r   rU   Queuer   r   r\  rX  rG   r  r  s   @rH   r  r  *  s    F  "#%5?+2+<+< % 12	
 '--(   U:

$%(: % %r<   r  )or   r   enumr   r   sysr  r   abcr   	itertoolsr   typesr   typingr   r   r   r	   r
   r   r   r   r   r   r   r   r   urllib.parser   r   r   r   utilsr   r  r   r   r   
auth.tokenr   eventr   r   r   r    version_infor#   r  redis.asyncio.retryr$   redis.backoffr%   redis.connectionr&   redis.credentialsr'   r(   redis.exceptionsr)   r*   r+   r,   r-   r.   r/   redis.typingr0   redis.utilsr1   r2   r3   _parsersr4   r5   r6   r7   r8   r[  r_  r\  SYM_LFrZ  Enumr>   rF   r   r!  rI   rK   rX   r  rU   r  r  r  r  r  r  r  r  r   rW  r  r:  rE   r  r2  r3  r4  r  r@   r<   rH   <module>r     s@        
     "    B A !77
CJJK ' F 9 z!06 % # 1 T   $ H H  
				   E+->@SSTU U'M%M>h >D8 D 02NNO r	' r	'j6*# 6*rL,J L,^N Nb!3 0 /htn  CS"'##!$%$:$:C GC#v+)>$>? "IU 23 2= 2j e+,j jZM%^ M%r<   