
    Kg                        S r SS/rSSKrSSKrSSKrSSKrSSKJrJr   SSK	r	SSKJrJrJrJr  \(       a  SSKJr  \R%                  S5         " S	 S
\R&                  5      r " S S\R(                  R*                  5      r SSS.S\S\S\S\S\\R0                  \4   4
S jjjrS\S\S\S\R4                  4S jrS\S\4S jrS\4S jrg! \
 a    Sr	 Nf = f)z
Utilities.	to_threadopen_connection    N)ReadTimeoutErrorWriteTimeoutError)TYPE_CHECKINGAnyCallableTuple)MySQLConnectionAbstractStreamWriterc                   >    \ rS rSrSrS\R                  SS4S jrSrg)StreamReaderProtocol8   zExtends asyncio.streams.StreamReaderProtocol for adding start_tls().

The ``start_tls()`` is based on ``asyncio.streams.StreamWriter`` introduced
in Python 3.11. It provides the same functionality for older Python versions.
writerreturnNc                 d    UR                   nXl        X l        UR                  S5      SLU l        g)z9Replace stream writer.

Args:
    writer: Stream Writer.

sslcontextN)	transport_stream_writer
_transportget_extra_info	_over_ssl)selfr   r   s      KC:\xampp\htdocs\balanca\venv\Lib\site-packages\mysql/connector/aio/utils.py_replace_writer$StreamReaderProtocol._replace_writer?   s1     $$	$#"11,?tK    )r   r   r   )	__name__
__module____qualname____firstlineno____doc__asyncior   r   __static_attributes__ r   r   r   r   8   s#    	Lg&:&: 	Lt 	Lr   r   c            	       P    \ rS rSrSrSSS.S\R                  S\S\SS4S	 jjr	S
r
g)r   K   zExtends asyncio.streams.StreamWriter for adding start_tls().

The ``start_tls()`` is based on ``asyncio.streams.StreamWriter`` introduced
in Python 3.11. It provides the same functionality for older Python versions.
N)server_hostnamessl_handshake_timeoutssl_contextr(   r)   r   c          	        #    U R                   R                  SLnU R                   nU R                  5       I Sh  vN   U R                  R	                  U R
                  UUUUUS9I Sh  vN nUU l        UR                  U 5        g NM N7f)zUpgrade an existing stream-based connection to TLS.

Args:
    ssl_context: Configured SSL context.
    server_hostname: Server host name.
    ssl_handshake_timeout: SSL handshake timeout.
N)server_sider(   r)   )	_protocol_client_connected_cbdrain_loop	start_tlsr   r   )r   r*   r(   r)   r,   protocolnew_transports          r   r1   StreamWriter.start_tlsR   s      nn99E>>jjl"jj22OO#+"7 3 
 
  	 	  & 	
s!   8BB/B*B
+B
B)r   )r   r   r    r!   r"   ssl
SSLContextstrintr1   r$   r%   r   r   r   r   K   sC      $%)'^^' 	'
  #' 
' 'r   i   )limithostportr9   kwdsr   c                   ^	#    [         R                  " 5       n[         R                  R                  X$S9n[	        XTS9m	UR
                  " U	4S jX40 UD6I Sh  vN u  pg[        UT	XT5      nXX4$  N7f)a  A wrapper for create_connection() returning a (reader, writer) pair.

This function is based on ``asyncio.streams.open_connection`` and adds a custom
stream reader.

MySQL expects TLS negotiation to happen in the middle of a TCP connection, not at
the start.
This function in conjunction with ``_StreamReaderProtocol`` and ``_StreamWriter``
allows the TLS negotiation on an existing connection.

Args:
    host: Server host name.
    port: Server port.
    limit: The buffer size limit used by the returned ``StreamReader`` instance.
           By default the limit is set to 64 KiB.

Returns:
    tuple: Returns a pair of reader and writer objects that are instances of
           ``StreamReader`` and ``StreamWriter`` classes.
)r9   loop)r>   c                     > T $ Nr%   )r2   s   r   <lambda>!open_connection.<locals>.<lambda>   s    r   N)r#   get_running_loopstreamsStreamReaderr   create_connectionr   )
r:   r;   r9   r<   r>   readerr   _r   r2   s
            @r   r   r   r   sq     . ##%D__)))AF#F6H//0@$UPTUULI)Xv<F> Vs   AA3A1A3funcargskwargsc                    #    [         R                  " 5       n[        R                  " 5       n[        R
                  " UR                  U /UQ70 UD6nUR                  SU5      I Sh  vN $  N7f)a9  Asynchronously run function ``func`` in a separate thread.

This function is based on ``asyncio.to_thread()`` introduced in Python 3.9, which
provides the same functionality for older Python versions.

Returns:
    coroutine: A coroutine that can be awaited to get the eventual result of
               ``func``.
N)r#   rC   contextvarscopy_context	functoolspartialrunrun_in_executor)rI   rJ   rK   r>   ctx	func_calls         r   r   r      s\      ##%D

"
"
$C!!#''4A$A&AI%%dI6666s   A%A.'A,(A.reasonc                 0   ^  S[         S[         4U 4S jjnU$ )z&Use it to decorate deprecated methods.rI   r   c                 r   >^  [         R                  " T 5      S[        S[        S[        4U U4S jj5       nU$ )NrJ   rK   r   c                     >#    [         R                  " STR                   ST 3[        SS9  T" U 0 UD6I S h  vN $  N7f)NzCall to deprecated function z
. Reason:    )category
stacklevel)warningswarnr   DeprecationWarning)rJ   rK   rI   rU   s     r   wrapper.deprecated.<locals>.decorator.<locals>.wrapper   sD     MM.t}}oZxP+
 t.v....s   6A >A )rO   wrapsr   r	   )rI   r_   rU   s   ` r   	decoratordeprecated.<locals>.decorator   s:    			/ 	/ 	/ 	/ 
	/ r   r	   )rU   rb   s   ` r   
deprecatedre      s    
 
X 
 r   c                  (    S[         S[         4S jn U $ )z
Decorator to close the current connection if a read or a write timeout
is raised by the method passed via the func parameter.

cnx_methodr   c           	      r   ^  [         R                  " T 5      SSS[        S[        S[        4U 4S jj5       nU$ )Ncnxr   rJ   rK   r   c                    >#     T" U /UQ70 UD6I S h  vN $  N! [          a;  n[        U[        [        45      (       a  U R	                  5       I S h  vN    UeS nAff = f7fr@   )	Exception
isinstancer   r   close)ri   rJ   rK   errrg   s       r   handle_cnx_methodGhandle_read_write_timeout.<locals>.decorator.<locals>.handle_cnx_method   s]     '=d=f==== c$46G#HII))+%%	s<   A#  A# 
A .AAAA  A#)rO   ra   r   )rg   ro   s   ` r   rb   ,handle_read_write_timeout.<locals>.decorator   sF    		$	*	36	BE		 
%	 ! r   rd   )rb   s    r   handle_read_write_timeoutrr      s    !h !8 ! r   )NN)r"   __all__r#   rM   rO   r\   mysql.connector.errorsr   r   r5   ImportErrortypingr   r   r	   r
   mysql.connector.aio.abstractsr   appendr   rD   r   r7   r8   rE   r   Futurer   re   rr   r%   r   r   <module>rz      s  @ )
*     F 7 6ENN>"L777 L&$'7??// $'P #'8=
25GJ
7-.>7( 73 7# 7'.. 7 s x $8 M  
Cs   C CC