
    *h                        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	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\\R(                  \4   4
S jjjrS\
S\	S\	S\R,                  4S jrg! \ a    Sr Nf = f)z
Utilities.	to_threadopen_connection    N)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)StreamReaderProtocol5   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      Q/var/www/auris/envauris/lib/python3.13/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   5   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
   H   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   r/   StreamWriter.start_tlsO   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intr/   r"   r#   r   r   r
   r
   H   sC      $%)'^^' 	'
  #' 
' 'r   i   )limithostportr7   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.
)r7   loop)r<   c                     > T $ )Nr#   )r0   s   r   <lambda>!open_connection.<locals>.<lambda>   s    r   N)r!   get_running_loopstreamsStreamReaderr   create_connectionr
   )
r8   r9   r7   r:   r<   readerr   _r   r0   s
            @r   r   r   o   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!   r@   contextvarscopy_context	functoolspartialrunrun_in_executor)rF   rG   rH   r<   ctx	func_calls         r   r   r      s\      ##%D

"
"
$C!!#''4A$A&AI%%dI6666s   A%A.'A,(A.)NN)r    __all__r!   rJ   rL   r3   ImportErrortypingr   r   r   r   mysql.connector.aio.abstractsr	   appendr   rA   r
   r5   r6   rB   r   Futurer   r#   r   r   <module>rX      s   @ )
*    7 6ENN>"L777 L&$'7??// $'P #'8=
25GJ
7-.>7( 73 7# 7'.. 7I  
Cs   B3 3B>=B>