§
    >Ä³gñ  ã                   óŽ  — d Z ddgZddlZddlZddlZddlZddlmZmZ 	 ddl	Z	n# e
$ r dZ	Y nw xY wddlmZmZmZmZ erddlmZ e                     d¦  «          G d	„ d
ej        ¦  «        Z G d„ dej        j        ¦  «        Z	 dddœdededededeej        ef         f
d„Zdedededej        fd„Zdedefd„Zdefd„ZdS )z
Utilities.Ú	to_threadÚopen_connectioné    N)ÚReadTimeoutErrorÚWriteTimeoutError)ÚTYPE_CHECKINGÚAnyÚCallableÚTuple)ÚMySQLConnectionAbstractÚStreamWriterc                   ó,   — e Zd ZdZdej        ddfd„ZdS )ÚStreamReaderProtocolzìExtends 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                 óh   — |j         }|| _        || _        |                     d¦  «        du| _        dS )zQReplace stream writer.

        Args:
            writer: Stream Writer.
        Ú
sslcontextN)Ú	transportÚ_stream_writerÚ
_transportÚget_extra_infoÚ	_over_ssl)Úselfr   r   s      úW/var/www/html/mpstechhub/venv/lib/python3.11/site-packages/mysql/connector/aio/utils.pyÚ_replace_writerz$StreamReaderProtocol._replace_writer?   s9   € ð Ô$ˆ	Ø$ˆÔØ#ˆŒØ"×1Ò1°,Ñ?Ô?ÀtÐKˆŒˆˆó    )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úasyncior   r   © r   r   r   r   8   sK   € € € € € ðð ð	L gÔ&:ð 	L¸tð 	Lð 	Lð 	Lð 	Lð 	Lð 	Lr   r   c            	       ó<   — e Zd ZdZdddœdej        dededdfd„ZdS )	r   zäExtends 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             ƒ   óö   K  — | j         j        du}| j         }|                      ¦   «         ƒ d{V —† | j                             | j        |||||¬¦  «        ƒ d{V —†}|| _        |                     | ¦  «         dS )zåUpgrade 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,   zStreamWriter.start_tlsR   s´   è è € ð ”nÔ9ÀÐEˆØ”>ˆØ�jŠj‰lŒlÐÐÐÐÐÐÐØ"œj×2Ò2àŒOØØØ#Ø+Ø"7ð 3ñ 
ô 
ð 
ð 
ð 
ð 
ð 
ð 
ˆð ð 	Œð 	× Ò  Ñ&Ô&Ð&Ð&Ð&r   )	r   r   r   r   ÚsslÚ
SSLContextÚstrÚintr,   r!   r   r   r   r   K   sl   € € € € € ðð ð  $Ø%)ð'ð 'ð 'à”^ð'ð ð	'ð
  #ð'ð 
ð'ð 'ð 'ð 'ð 'ð 'r   i   )ÚlimitÚhostÚportr3   Úkwdsr   c             ‹   óö   ‡	K  — t          j        ¦   «         }t           j                             ||¬¦  «        }t	          ||¬¦  «        Š	 |j        ˆ	fd„| |fi |¤Žƒ d{V —†\  }}t          |‰	||¦  «        }||fS )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.
    )r3   Úloop)r8   c                  ó   •— ‰ S ©Nr!   )r-   s   €r   ú<lambda>z!open_connection.<locals>.<lambda>Œ   s   ø€ ¸€ r   N)r    Úget_running_loopÚstreamsÚStreamReaderr   Úcreate_connectionr   )
r4   r5   r3   r6   r8   Úreaderr   Ú_r   r-   s
            @r   r   r   r   sŸ   øè è € õ. Ô#Ñ%Ô%€DÝŒ_×)Ò)°¸DÐ)ÑAÔA€FÝ# F°Ð6Ñ6Ô6€HØ/˜Ô/Ð0@Ð0@Ð0@Ð0@À$ÈÐUÐUÐPTÐUÐUÐUÐUÐUÐUÐUÐU�L€IˆqÝ˜) X¨v°tÑ<Ô<€FØ�6ˆ>Ðr   ÚfuncÚargsÚkwargsc              �   óÀ   K  — t          j        ¦   «         }t          j        ¦   «         }t	          j        |j        | g|¢R i |¤Ž}|                     d|¦  «        ƒ d{V —†S )aQ  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)rB   rC   rD   r8   ÚctxÚ	func_calls         r   r   r   ‘   sp   è è € õ Ô#Ñ%Ô%€DÝ
Ô
"Ñ
$Ô
$€CÝÔ! #¤'¨4ÐA°$ÐAÐAÐA¸&ÐAÐA€IØ×%Ò% d¨IÑ6Ô6Ð6Ð6Ð6Ð6Ð6Ð6Ð6r   Úreasonc                 ó0   ‡ — dt           dt           fˆ fd„}|S )z&Use it to decorate deprecated methods.rB   r   c                 óv   •‡ — t          j        ‰ ¦  «        dt          dt          dt          fˆ ˆfd„¦   «         }|S )NrC   rD   r   c               Ÿ   ór   •K  — t          j        d‰j        › d‰› �t          d¬¦  «          ‰| i |¤Žƒ d {V —†S )NzCall to deprecated function z
. Reason: é   )ÚcategoryÚ
stacklevel)ÚwarningsÚwarnr   ÚDeprecationWarning)rC   rD   rB   rN   s     €€r   Úwrapperz.deprecated.<locals>.decorator.<locals>.wrapper¥   sd   øè è € åŒMØP¨t¬}ÐPÐPÈÐPÐPÝ+Øðñ ô ð ð
 ˜˜tÐ. vÐ.Ð.Ð.Ð.Ð.Ð.Ð.Ð.Ð.r   )rH   Úwrapsr   r	   )rB   rX   rN   s   ` €r   Ú	decoratorzdeprecated.<locals>.decorator¤   sX   øø€ Ý	Œ˜Ñ	Ô	ð	/¥ð 	/µð 	/½ð 	/ð 	/ð 	/ð 	/ð 	/ð 	/ñ 
Ô	ð	/ð ˆr   ©r	   )rN   rZ   s   ` r   Ú
deprecatedr\   ¡   s7   ø€ ð
�ð 
¥Xð 
ð 
ð 
ð 
ð 
ð 
ð Ðr   c                  ó*   — dt           dt           fd„} | S )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           	      óv   ‡ — t          j        ‰ ¦  «        dddt          dt          dt          fˆ fd„¦   «         }|S )NÚcnxr   rC   rD   r   c              Ÿ   óÂ   •K  — 	  ‰| g|¢R i |¤Žƒ d {V —†S # t           $ r=}t          |t          t          f¦  «        r|                      ¦   «         ƒ d {V —† |‚d }~ww xY wr:   )Ú	ExceptionÚ
isinstancer   r   Úclose)r`   rC   rD   Úerrr^   s       €r   Úhandle_cnx_methodzGhandle_read_write_timeout.<locals>.decorator.<locals>.handle_cnx_methodº   s›   øè è € ðØ'˜Z¨Ð=¨dÐ=Ð=Ð=°fÐ=Ð=Ð=Ð=Ð=Ð=Ð=Ð=Ð=øÝð ð ð Ý˜cÕ$4Õ6GÐ#HÑIÔIð &ØŸ)š)™+œ+Ð%Ð%Ð%Ð%Ð%Ð%Ð%Ø�	øøøøðøøøs   … —
A¡8AÁA)rH   rY   r   )r^   rf   s   ` r   rZ   z,handle_read_write_timeout.<locals>.decorator¹   s^   ø€ Ý	Œ˜Ñ	$Ô	$ð	Ø*ð	Ý36ð	ÝBEð	åð	ð 	ð 	ð 	ð 	ñ 
%Ô	$ð	ð !Ð r   r[   )rZ   s    r   Úhandle_read_write_timeoutrg   ³   s,   € ð!�hð !­8ð !ð !ð !ð !ð Ðr   )NN)r   Ú__all__r    rF   rH   rU   Úmysql.connector.errorsr   r   r/   ÚImportErrorÚtypingr   r   r	   r
   Úmysql.connector.aio.abstractsr   Úappendr   r=   r   r1   r2   r>   r   ÚFuturer   r\   rg   r!   r   r   ú<module>ro      s  ðð@ Ð àÐ)Ð
*€à €€€Ø Ð Ð Ð Ø Ð Ð Ð Ø €€€à FÐ FÐ FÐ FÐ FÐ FÐ FÐ FðØ€J€J€J€JøØð ð ð Ø
€C€C€Cðøøøð 7Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6àð #ØEÐEÐEÐEÐEÐEà‡N‚N�>Ñ"Ô"Ð"ðLð Lð Lð Lð L˜7Ô7ñ Lô Lð Lð&$'ð $'ð $'ð $'ð $'�7”?Ô/ñ $'ô $'ð $'ðP #'ðØ8=ðð ð Ø
ðØðØ25ðØGJðà
ˆ7Ô Ð-Ô.ðð ð ð ð>7˜(ð 7¨3ð 7¸#ð 7À'Ä.ð 7ð 7ð 7ð 7ð �sð ˜xð ð ð ð ð$ 8ð ð ð ð ð ð s    % ¥/®/