§
    ¡˜ºhˆT  ã                  óÚ  — U d Z ddlmZ ddlZddlZddlZddlZddlmZ ddl	m
Z
mZmZmZmZmZmZ ddlmZ 	 ddlZddlZdZn# e$ r dZY nw xY w	 d	d
lmZ n# e$ r dZY nw xY wd	dlmZ d	dlmZmZ d	dlm Z m!Z!m"Z"m#Z#m$Z$ d	dl%m&Z&  ej'        ¦   «         Z(dZ)dZ* ej+        d¦  «        Z,dZ-e€eneefZ.de/d<   i Z0de/d<   d%d„Z1d&d„Z2d'd„Z3d(d!„Z4 G d"„ d¦  «        Z5 G d#„ d$¦  «        Z6dS ))z5Implementing pooling of connections to MySQL servers.é    )ÚannotationsN)ÚTracebackType)ÚAnyÚDictÚNoReturnÚOptionalÚTupleÚTypeÚUnion)Úuuid4TFé   )ÚCMySQLConnection)ÚMySQLConnection)ÚCNX_POOL_ARGSÚDEFAULT_CONFIGURATION)ÚErrorÚInterfaceErrorÚNotSupportedErrorÚ	PoolErrorÚProgrammingError)Úread_option_filesé    é@   z[^a-zA-Z0-9._:\-*$#]z0MySQL Connector/Python C Extension not availablezUnion[type, Tuple[type, ...]]ÚMYSQL_CNX_CLASSzDict[str, MySQLConnectionPool]Ú_CONNECTION_POOLSÚkwargsr   ÚreturnÚPooledMySQLConnectionc                 ó6  — d| v r| d         nt          d	i | ¤Ž}|                      d¦  «        du rt          €t          t          ¦  «        ‚t
          5  |t          vrt          d	i | ¤Žt          |<   nQt          t          |         t          ¦  «        r1t          |         j	        }d| v r| d         |k    rt          d¦  «        ‚ddd¦  «         n# 1 swxY w Y   	 t          |                              ¦   «         S # t          $ r t          d|› d�¦  «        d‚w xY w)
z!Return a pooled MySQL connection.Ú	pool_nameÚuse_pureFNÚ	pool_sizez)Size can not be changed for active pools.z%Failed getting connection from pool 'ú'© )Úgenerate_pool_nameÚgetr   ÚImportErrorÚERROR_NO_CEXTÚCONNECTION_POOL_LOCKr   ÚMySQLConnectionPoolÚ
isinstancer"   r   Úget_connectionÚAttributeErrorr   )r   r    Ú
check_sizes      ú_/var/www/html/services/rag-service/venv/lib/python3.11/site-packages/mysql/connector/pooling.pyÚ_get_pooled_connectionr0   M   sœ  € ð  +¨fÐ4Ð4ˆˆ{ÔÐÕ:LÐ:VÐ:VÈvÐ:VÐ:Vð ð ‡z‚z�*ÑÔ Ð&Ð&Õ+;Ð+CÝ�-Ñ(Ô(Ð(õ 
ð Mð MØÕ-Ð-Ð-Ý+>Ð+HÐ+HÀÐ+HÐ+HÕ˜iÑ(Ð(ÝÕ)¨)Ô4Õ6IÑJÔJð 	Må*¨9Ô5Ô?ˆJØ˜fÐ$Ð$¨°Ô)<À
Ò)JÐ)JÝÐ KÑLÔLÐLðMð Mð Mñ Mô Mð Mð Mð Mð Mð Mð Møøøð Mð Mð Mð MðÝ  Ô+×:Ò:Ñ<Ô<Ð<øÝð ð ð ÝØ@°IÐ@Ð@Ð@ñ
ô 
àð	ðøøøs   ÁA0CÃCÃCÃC9 Ã9Dú?Union[PooledMySQLConnection, MySQLConnection, CMySQLConnection]c                 ó~  — |                       ¦   «         }	 |d         }n# t          $ r t          d¦  «        d‚w xY w|d= t          g d¢¦  «        }d}|D ]ú}t          |                     ¦   «         ¦  «        |z
  }|rAt          |¦  «        dk    rdnd}d	                     |¦  «        }t          d
|› d|› �¦  «        ‚t          |d¦  «        r|dz  }|                     dd¦  «        |d<   |d         dk     s|d         dk    rt          d|d         › �¦  «        ‚t          |d         t          ¦  «        st          d|d         › �¦  «        ‚Œûd|cxk     rt          |¦  «        k     rn nt          d¦  «        ‚i }	g }
t          |d„ d¬¦  «        D ]U}|d         |	vr(|g|	|d         <   |
                     |d         ¦  «         Œ4|	|d                                       |¦  «         ŒV|
D ]Ä}|	|         }t          t          |¦  «        ¦  «        D ]�}t          |¦  «        dz
  }t!          j        d|¦  «        }|                     |¦  «        }|                      ¦   «         }|                     |¦  «         |                     dd¦  «         	 t)          di |¤Žc c S # t*          $ r Y Œšw xY wŒÅt          d¦  «        ‚)aª  Return a MySQL connection and try to failover if needed.

    An InterfaceError is raise when no MySQL is available. ValueError is
    raised when the failover server configuration contains an illegal
    connection argument. Supported arguments are user, password, host, port,
    unix_socket and database. ValueError is also raised when the failover
    argument was not provided.

    Returns MySQLConnection instance.
    Úfailoverzfailover argument not providedN)	ÚuserÚpasswordÚhostÚportÚunix_socketÚdatabaser    r"   Úpriorityr   r   ÚsÚ z, z Unsupported connection argument z in failover: r:   éd   z9Priority value should be in the range of 0 to 100, got : zDPriority value should be an integer in the range of 0 to 100, got : z\You must either assign no priority to any of the routers or give a priority for every routerc                ó   — | d         S )Nr:   r$   ©Úxs    r/   ú<lambda>z*_get_failover_connection.<locals>.<lambda>®   s
   € °°:´€ ó    T)ÚkeyÚreversez,Unable to connect to any of the target hostsr$   )ÚcopyÚKeyErrorÚ
ValueErrorÚsetÚkeysÚlenÚjoinÚhasattrr&   r   r+   Úintr   ÚsortedÚappendÚrangeÚrandomÚrandintÚpopÚupdateÚconnectr   )r   Úconfigr3   Úsupport_cnx_argsÚpriority_countÚserverÚdiffÚargÚlstÚserver_directoryÚserver_priority_listr:   Úfailover_listÚ_ÚlastÚindexÚ
new_configs                    r/   Ú_get_failover_connectionrd   j   s”  € ð �[Š[‰]Œ]€FðEØ˜*Ô%ˆˆøÝð Eð Eð EÝÐ9Ñ:Ô:ÀÐDðEøøøàˆzÐåð
	
ð 
	
ð 
	
ñô Ðð €NØð ð ˆÝ�6—;’;‘=”=Ñ!Ô!Ð$4Ñ4ˆØð 	Ý˜T™œ Qš˜�#�#¨BˆCØ—)’)˜D‘/”/ˆCÝØK°3ÐKÐKÀcÐKÐKñô ð õ �6˜:Ñ&Ô&ð 	 Ø˜aÑˆNà#ŸZšZ¨
°CÑ8Ô8ˆˆzÑØ�*Ô Ò!Ð! V¨JÔ%7¸#Ò%=Ð%=Ý ð.Ø 
Ô+ð.ð .ñô ð õ ˜& Ô,­cÑ2Ô2ð 	Ý ð3Ø$ ZÔ0ð3ð 3ñô ð ð	ð 	ˆ>Ð)Ð)Ò)Ð)�C ™MœMÒ)Ð)Ð)Ð)Ð)Ýðñ
ô 
ð 	
ð ÐØÐÝ˜Ð'>Ð'>ÈÐMÑMÔMð @ð @ˆØ�*ÔÐ%5Ð5Ð5Ø4:°8Ð˜V JÔ/Ñ0Ø ×'Ò'¨¨zÔ(:Ñ;Ô;Ð;Ð;à˜V JÔ/Ô0×7Ò7¸Ñ?Ô?Ð?Ð?à(ð ð ˆØ(¨Ô2ˆÝ•s˜=Ñ)Ô)Ñ*Ô*ð 	ð 	ˆAÝ�}Ñ%Ô%¨Ñ)ˆDÝ”N 1 dÑ+Ô+ˆEØ"×&Ò& uÑ-Ô-ˆFØŸš™œˆJØ×Ò˜fÑ%Ô%Ð%Ø�NŠN˜: tÑ,Ô,Ð,ðÝÐ,Ð, Ð,Ð,Ð,Ð,Ð,Ð,Ð,øÝð ð ð à�ðøøøð	õ ÐGÑ
HÔ
HÐHs   – Ÿ:ÊJÊ
J,Ê+J,Úargsc                 ó²  ‡— d‰v r‰                      d¦  «        nd}t          |t          ¦  «        st          d¦  «        ‚|�r,t          st          d¦  «        ‚d‰v rt          d¦  «        ‚d‰v rt          d¦  «        ‚d	‰v rt          d
¦  «        ‚d‰vrt
          d         ‰d<   	 t          j                             ‰d         d¦  «        }n2# t          j	        j
        $ r t          d‰d         › d�¦  «        d‚w xY wg }|D ]D}|                     |j                             d¬¦  «        |j        |j        |j        dœ¦  «         ŒE|                     d„ ¬¦  «         d„ |D ¦   «         ‰d	<   d‰v r ‰d         ‰d<   ‰                      d¦  «         d‰v rt%          di ‰¤Ž}t'          di |¤ŽS d	‰v rt)          di ‰¤ŽS 	 t+          ˆfd„t,          D ¦   «         ¦  «        rt/          di ‰¤ŽS n# t0          $ r Y nw xY w‰                     dd¦  «        }d‰v r ‰d= |st4          €t7          t8          ¦  «        ‚t4          r|st5          | i ‰¤ŽS t;          | i ‰¤ŽS )a�  Create or get a MySQL connection object.

    In its simpliest form, connect() will open a connection to a
    MySQL server and return a MySQLConnection object.

    When any connection pooling arguments are given, for example pool_name
    or pool_size, a pool is created or a previously one is used to return
    a PooledMySQLConnection.

    Returns MySQLConnection or PooledMySQLConnection.
    Údns_srvFz(The value of 'dns-srv' must be a booleanztMySQL host configuration requested DNS SRV. This requires the Python dnspython module. Please refer to documentationr8   z<Using Unix domain sockets with DNS SRV lookup is not allowedr7   z;Specifying a port number with DNS SRV lookup is not allowedr3   zASpecifying multiple hostnames with DNS SRV look up is not allowedr6   ÚSRVz Unable to locate any hosts for 'r#   NT)Úomit_final_dot)r6   r7   r:   Úweightc                ó$   — | d         | d          fS )Nr:   rj   r$   r?   s    r/   rA   zconnect.<locals>.<lambda>  s   €  Q z¤]°Q°x´[°LÐ$A€ rB   )rC   c                ó0   — g | ]}|d          |d         dœ‘ŒS )r6   r7   )r6   r7   r$   )Ú.0Úsrvs     r/   ú
<listcomp>zconnect.<locals>.<listcomp>  s5   € ð 
ð 
ð 
Ø;>�S˜”[¨#¨f¬+Ð6Ð6ð
ð 
ð 
rB   Úread_default_fileÚoption_filesc              3  ó    •K  — | ]}|‰v V — Œ	d S ©Nr$   )rm   rC   r   s     €r/   ú	<genexpr>zconnect.<locals>.<genexpr>  s'   øè è € Ð6Ð6 ˆs�fˆ}Ð6Ð6Ð6Ð6Ð6Ð6rB   r!   r$   )rS   r+   Úboolr   ÚHAVE_DNSPYTHONr   ÚdnsÚresolverÚqueryÚ	exceptionÚDNSExceptionrO   ÚtargetÚto_textr7   r:   rj   Úsortr   rU   rd   Úanyr   r0   Ú	NameErrorr&   r   r'   r(   r   )re   r   rg   Úsrv_recordsr3   rn   rc   r!   s    `      r/   rU   rU   Ç   sT  ø€ ð (1°FÐ':Ð':ˆf�jŠj˜Ñ#Ô#Ð#À€Gå�g�tÑ$Ô$ð IÝÐGÑHÔHÐHàñ +
Ýð 	Ý ð8ñô ð ð
 ˜FÐ"Ð"Ý ØNñô ð ð �VÐÐÝ ØMñô ð ð ˜ÐÐÝ ØSñô ð ð ˜ÐÐÝ2°6Ô:ˆF�6‰Nð	Ýœ,×,Ò,¨V°F¬^¸UÑCÔCˆKˆKøÝŒ}Ô)ð 	ð 	ð 	Ý ØD°6¸&´>ÐDÐDÐDñô àðð	øøøð
 ˆØð 	ð 	ˆCØ�OŠOàœJ×.Ò.¸dÐ.ÑCÔCØœHØ #¤Ø!œjð	ð ñô ð ð ð 	�ŠÐAÐAˆÑBÔBÐBð
ð 
ØBJð
ñ 
ô 
ˆˆzÑð
 ˜fÐ$Ð$Ø!'Ð(;Ô!<ˆˆ~ÑØ�
Š
Ð&Ñ'Ô'Ð'à˜ÐÐÝ&Ð0Ð0¨Ð0Ð0ˆ
ÝÐ$Ð$˜Ð$Ð$Ð$ð �VÐÐÝ'Ð1Ð1¨&Ð1Ð1Ð1ðÝÐ6Ð6Ð6Ð6­Ð6Ñ6Ô6Ñ6Ô6ð 	4Ý)Ð3Ð3¨FÐ3Ð3Ð3ð	4øåð ð ð àˆðøøøð
 �zŠz˜* eÑ,Ô,€HØ�VÐÐØ�:ÐØð 	-Õ,Ð4Ý�mÑ,Ô,Ð,åð 1 ð 1Ý Ð0¨Ð0Ð0Ð0Ý˜DÐ+ FÐ+Ð+Ð+s   Â(&C Ã/C>Ç+G. Ç.
G;Ç:G;Ústrc                 óÎ   — g }dD ];}	 |                      t          | |         ¦  «        ¦  «         Œ,# t          $ r Y Œ8w xY w|st          d¦  «        ‚d                     |¦  «        S )zøGenerate a pool name

    This function takes keyword arguments, usually the connection
    arguments for MySQLConnection, and tries to generate a name for
    a pool.

    Raises PoolError when no name can be generated.

    Returns a string.
    )r6   r7   r4   r9   z.Failed generating pool name; specify pool_namer`   )rO   r‚   rF   r   rK   )r   ÚpartsrC   s      r/   r%   r%   )  sˆ   € ð €EØ3ð ð ˆð	Ø�LŠL�˜V Cœ[Ñ)Ô)Ñ*Ô*Ð*Ð*øÝð 	ð 	ð 	ØˆDð	øøøð ð JÝÐHÑIÔIÐIà�8Š8�E‰?Œ?Ðs   ˆ(1±
>½>c                  ój   — e Zd ZdZdd„Zdd	„Zdd„Zdd„Zdd„Ze	d d„¦   «         Z
ed!d„¦   «         ZdS )"r   a  Class holding a MySQL Connection in a pool

    PooledMySQLConnection is used by MySQLConnectionPool to return an
    instance holding a MySQL connection. It works like a MySQLConnection
    except for methods like close() and config().

    The close()-method will add the connection back to the pool rather
    than disconnecting from the MySQL server.

    Configuring the connection have to be done through the MySQLConnectionPool
    method set_config(). Using config() on pooled connection will raise a
    PoolError.
    Úpoolr*   Úcnxú(Union[MySQLConnection, CMySQLConnection]r   ÚNonec                ó²   — t          |t          ¦  «        st          d¦  «        ‚t          |t          ¦  «        st          d¦  «        ‚|| _        || _        dS )z‰Initialize

        The pool argument must be an instance of MySQLConnectionPoll. cnx
        if an instance of MySQLConnection.
        z$pool should be a MySQLConnectionPoolzcnx should be a MySQLConnectionN)r+   r*   r-   r   Ú	_cnx_poolÚ_cnx)Úselfr†   r‡   s      r/   Ú__init__zPooledMySQLConnection.__init__P  s[   € õ ˜$Õ 3Ñ4Ô4ð 	IÝ Ð!GÑHÔHÐHÝ˜#�Ñ/Ô/ð 	DÝ Ð!BÑCÔCÐCØ.2ˆŒØ>AˆŒ	ˆ	ˆ	rB   c                ó   — | S rs   r$   ©r�   s    r/   Ú	__enter__zPooledMySQLConnection.__enter___  s   € ØˆrB   Úexc_typeúType[BaseException]Ú	exc_valueÚBaseExceptionÚ	tracebackr   c                ó.   — |                       ¦   «          d S rs   )Úclose)r�   r’   r”   r–   s       r/   Ú__exit__zPooledMySQLConnection.__exit__b  s   € ð 	�
Š
‰ŒˆˆˆrB   Úattrr   c                ó,   — t          | j        |¦  «        S )z0Calls attributes of the MySQLConnection instance)ÚgetattrrŒ   )r�   rš   s     r/   Ú__getattr__z!PooledMySQLConnection.__getattr__j  s   € å�t”y $Ñ'Ô'Ð'rB   c                óä   — 	 | j         }| j        j        r|                     ¦   «          | j                             |¦  «         d| _         dS # | j                             |¦  «         d| _         w xY w)aY  Do not close, but add connection back to pool

        The close() method does not close the connection with the
        MySQL server. The connection is added back to the pool so it
        can be reused.

        When the pool is configured to reset the session, the session
        state will be cleared by re-authenticating the user.
        N)rŒ   r‹   Úreset_sessionÚadd_connection©r�   r‡   s     r/   r˜   zPooledMySQLConnection.closen  sz   € ð	Ø”)ˆCØŒ~Ô+ð $Ø×!Ò!Ñ#Ô#Ð#àŒN×)Ò)¨#Ñ.Ô.Ð.ØˆDŒIˆIˆIøð ŒN×)Ò)¨#Ñ.Ô.Ð.ØˆDŒIÐÐÐÐs   ‚'A Á#A/r   r   c                 ó    — t          d¦  «        ‚)z&Configuration is done through the poolzKConfiguration for pooled connections should be done through the pool itself)r   )r   s    r/   rV   zPooledMySQLConnection.config€  s   € õ ðñ
ô 
ð 	
rB   r‚   c                ó   — | j         j        S ©z&Return the name of the connection pool)r‹   r    r�   s    r/   r    zPooledMySQLConnection.pool_nameˆ  s   € ð Œ~Ô'Ð'rB   N)r†   r*   r‡   rˆ   r   r‰   ©r   r   )r’   r“   r”   r•   r–   r   r   r‰   )rš   r   r   r   )r   r‰   )r   r   r   r   ©r   r‚   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__rŽ   r‘   r™   r�   r˜   ÚstaticmethodrV   Úpropertyr    r$   rB   r/   r   r   A  sÆ   € € € € € ðð ðBð Bð Bð Bðð ð ð ðð ð ð ð(ð (ð (ð (ðð ð ð ð$ ð
ð 
ð 
ñ „\ð
ð ð(ð (ð (ñ „Xð(ð (ð (rB   c                  ó¦   — e Zd ZdZ	 	 	 dd d„Zed!d„¦   «         Zed"d„¦   «         Zed#d„¦   «         Zd$d„Z	d%d„Z
d&d„Zd'd„Z	 d(d)d„Zd*d„Zd"d„ZdS )+r*   z*Class defining a pool of MySQL connectionsé   NTr"   rM   r    úOptional[str]Úpool_reset_sessionru   r   r   r   r‰   c                ó”  — d| _         d| _        || _        |                      |¦  «         |                      |pt          di |¤Ž¦  «         i | _        t          j        | j         ¦  «        | _	        t          ¦   «         | _        |r@ | j        di |¤Ž d}|| j         k     r(|                      ¦   «          |dz  }|| j         k     °$dS dS dS )zõInitialize

        Initialize a MySQL connection pool with a maximum number of
        connections set to pool_size. The rest of the keywords
        arguments, kwargs, are configuration arguments for MySQLConnection
        instances.
        Nr   r   r$   )Ú
_pool_sizeÚ
_pool_nameÚ_reset_sessionÚ_set_pool_sizeÚ_set_pool_namer%   Ú_cnx_configÚqueueÚQueueÚ
_cnx_queuer   Ú_config_versionÚ
set_configr    )r�   r"   r    r°   r   Úcnts         r/   rŽ   zMySQLConnectionPool.__init__‘  sø   € ð *.ˆŒØ)-ˆŒØ0ˆÔØ×Ò˜IÑ&Ô&Ð&Ø×Ò˜IÐEÕ);Ð)EÐ)E¸fÐ)EÐ)EÑFÔFÐFØ+-ˆÔõ ŒK˜œÑ(Ô(ð 	Œõ  %™wœwˆÔàð 	ØˆDŒOÐ%Ð%˜fÐ%Ð%Ð%ØˆCØ˜œÒ'Ð'Ø×#Ò#Ñ%Ô%Ð%Ø�q‘�ð ˜œÒ'Ð'Ð'Ð'ð	ð 	ð (Ð'rB   r‚   c                ó   — | j         S r¤   )r³   r�   s    r/   r    zMySQLConnectionPool.pool_name±  ó   € ð ŒÐrB   c                ó   — | j         S )z0Return number of connections managed by the pool)r²   r�   s    r/   r"   zMySQLConnectionPool.pool_size¶  r¿   rB   c                ó   — | j         S )zReturn whether to reset session)r´   r�   s    r/   rŸ   z!MySQLConnectionPool.reset_session»  s   € ð Ô"Ð"rB   c                ó  — |sdS t           5  	 t          ¦   «         } |j        di |¤Ž || _        t	          ¦   «         | _        n%# t          $ r}t          d|› �¦  «        |‚d}~ww xY w	 ddd¦  «         dS # 1 swxY w Y   dS )aT  Set the connection configuration for MySQLConnection instances

        This method sets the configuration used for creating MySQLConnection
        instances. See MySQLConnection for valid connection arguments.

        Raises PoolError when a connection argument is not valid, missing
        or not supported by MySQLConnection.
        Nz$Connection configuration not valid: r$   )r)   rU   rV   r·   r   r»   r-   r   )r�   r   Útest_cnxÚerrs       r/   r¼   zMySQLConnectionPool.set_configÀ  s  € ð ð 	ØˆFå!ð 	Wð 	WðWÝ"™9œ9�Ø�”Ð)Ð) &Ð)Ð)Ð)Ø#)�Ô Ý',¡w¤w�Ô$Ð$øÝ!ð Wð Wð WÝÐ LÀsÐ LÐ LÑMÔMÐSVÐVøøøøðWøøøð %ð	Wð 	Wð 	Wñ 	Wô 	Wð 	Wð 	Wð 	Wð 	Wð 	Wð 	Wð 	Wøøøð 	Wð 	Wð 	Wð 	Wð 	Wð 	Ws4   ŒA7Ž5AÁA7Á
A&ÁA!Á!A&Á&A7Á7A;Á>A;c                ód   — |dk    s|t           k    rt          dt           › �¦  «        ‚|| _        dS )a  Set the size of the pool

        This method sets the size of the pool but it will not resize the pool.

        Raises an AttributeError when the pool_size is not valid. Invalid size
        is 0, negative or higher than pooling.CNX_POOL_MAXSIZE.
        r   z8Pool size should be higher than 0 and lower or equal to N)ÚCNX_POOL_MAXSIZEr-   r²   )r�   r"   s     r/   rµ   z"MySQLConnectionPool._set_pool_sizeÕ  sI   € ð ˜Š>ˆ>˜YÕ)9Ò9Ð9Ý ð&Ý#ð&ð &ñô ð ð $ˆŒˆˆrB   c                óÄ   — t                                |¦  «        rt          d|› d�¦  «        ‚t          |¦  «        t          k    rt          d|› d�¦  «        ‚|| _        dS )a  Set the name of the pool.

        This method checks the validity and sets the name of the pool.

        Raises an AttributeError when pool_name contains illegal characters
        ([^a-zA-Z0-9._\-*$#]) or is longer than pooling.CNX_POOL_MAXNAMESIZE.
        zPool name 'z' contains illegal charactersz' is too longN)ÚCNX_POOL_NAMEREGEXÚsearchr-   rJ   ÚCNX_POOL_MAXNAMESIZEr³   )r�   r    s     r/   r¶   z"MySQLConnectionPool._set_pool_nameä  sl   € õ ×$Ò$ YÑ/Ô/ð 	YÝ Ð!W¨yÐ!WÐ!WÐ!WÑXÔXÐXÝˆy‰>Œ>Õ0Ò0Ð0Ý Ð!G¨yÐ!GÐ!GÐ!GÑHÔHÐHØ#ˆŒˆˆrB   r‡   rˆ   c                óÖ   — t          |t          ¦  «        st          d¦  «        ‚	 | j                             |d¬¦  «         dS # t
          j        $ r}t          d¦  «        |‚d}~ww xY w)zôPut connection back in the queue

        This method is putting a connection back in the queue. It will not
        acquire a lock as the methods using _queue_connection() will have it
        set.

        Raises PoolError on errors.
        ú3Connection instance not subclass of MySQLConnectionF©Úblockú'Failed adding connection; queue is fullN)r+   r   r   rº   Úputr¸   ÚFull©r�   r‡   rÄ   s      r/   Ú_queue_connectionz%MySQLConnectionPool._queue_connectionò  sƒ   € õ ˜#�Ñ/Ô/ð 	SÝÐQÑRÔRÐRð	PØŒO×Ò ¨5ÐÑ1Ô1Ð1Ð1Ð1øÝŒzð 	Pð 	Pð 	PÝÐEÑFÔFÈCÐOøøøøð	Pøøøs   ¦A ÁA(ÁA#Á#A(ú2Optional[Union[MySQLConnection, CMySQLConnection]]c                ó  — t           5  | j        st          d¦  «        ‚| j                             ¦   «         rt          d¦  «        ‚|skt          di | j        ¤Ž}	 | j        r4| j        d         r'|                     ¦   «         dk     rt          d¦  «        ‚n# t          $ r Y nw xY w| j
        |_        n$t          |t          ¦  «        st          d¦  «        ‚|                      |¦  «         ddd¦  «         dS # 1 swxY w Y   dS )	aá  Add a connection to the pool

        This method instantiates a MySQLConnection using the configuration
        passed when initializing the MySQLConnectionPool instance or using
        the set_config() method.
        If cnx is a MySQLConnection instance, it will be added to the
        queue.

        Raises PoolError when no configuration is set, when no more
        connection can be added (maximum reached) or when the connection
        can not be instantiated.
        z&Connection configuration not availablerÏ   Úcompress)r®   é   é   z^Pool reset session is not supported with compression for MySQL server version 5.7.2 or earlierrÌ   Nr$   )r)   r·   r   rº   ÚfullrU   r´   Úget_server_versionr   rF   r»   Úpool_config_versionr+   r   rÓ   r¡   s     r/   r    z"MySQLConnectionPool.add_connection  s�  € õ "ð 	(ð 	(ØÔ#ð JÝÐ HÑIÔIÐIàŒ×#Ò#Ñ%Ô%ð KÝÐ IÑJÔJÐJàð ÝÐ1Ð1 Ô 0Ð1Ð1�ðàÔ+ð	à Ô,¨ZÔ8ð	ð  ×2Ò2Ñ4Ô4°yÒ@Ð@å/ð)ñô ð øøõ
  ð ð ð Ø�Dðøøøð +/Ô*>�Ô'Ð'å! #¥Ñ7Ô7ð Ý#ØMñô ð ð ×"Ò" 3Ñ'Ô'Ð'ð=	(ð 	(ð 	(ñ 	(ô 	(ð 	(ð 	(ð 	(ð 	(ð 	(ð 	(ð 	(øøøð 	(ð 	(ð 	(ð 	(ð 	(ð 	(s7   ˆAC:Á;BÂC:Â
B$Â!C:Â#B$Â$A	C:Ã:C>ÄC>r   c                óä  — t           5  	 | j                             d¬¦  «        }n'# t          j        $ r}t          d¦  «        |‚d}~ww xY w|                     ¦   «         r| j        |j        k    rX |j	        di | j
        ¤Ž 	 |                     ¦   «          n$# t          $ r |                      |¦  «         ‚ w xY w| j        |_        t          | |¦  «        cddd¦  «         S # 1 swxY w Y   dS )aw  Get a connection from the pool

        This method returns an PooledMySQLConnection instance which
        has a reference to the pool that created it, and the next available
        MySQL connection.

        When the MySQL connection is not connect, a reconnect is attempted.

        Raises PoolError on errors.

        Returns a PooledMySQLConnection instance.
        FrÍ   z)Failed getting connection; pool exhaustedNr$   )r)   rº   r&   r¸   ÚEmptyr   Úis_connectedr»   rÛ   rV   r·   Ú	reconnectr   rÓ   r   rÒ   s      r/   r,   z"MySQLConnectionPool.get_connection2  sg  € õ "ð 	4ð 	4ðVØ”o×)Ò)°Ð)Ñ6Ô6��øÝ”;ð Vð Vð VÝÐ KÑLÔLÐRUÐUøøøøðVøøøð ×$Ò$Ñ&Ô&ð?àÔ'¨3Ô+BÒBÐBà�”
Ð.Ð.˜TÔ-Ð.Ð.Ð.ðØ—M’M‘O”O�O�OøÝ%ð ð ð à×*Ò*¨3Ñ/Ô/Ð/Øðøøøð +/Ô*>�Ô'å(¨¨sÑ3Ô3ð'	4ð 	4ð 	4ð 	4ñ 	4ô 	4ð 	4ð 	4ð 	4ð 	4ð 	4ð 	4øøøð 	4ð 	4ð 	4ð 	4ð 	4ð 	4sH   ˆC%Š&¥C%¦A
µAÁA
Á
9C%ÂBÂC%Â!B:Â:C%Ã%C)Ã,C)c                ó|  — t           5  d}| j        }|                     ¦   «         r}	 |                     d¬¦  «        }|                     ¦   «          |dz  }n8# t
          j        $ r |cY cddd¦  «         S t          $ r ‚ t          $ r Y nw xY w|                     ¦   «         °}|cddd¦  «         S # 1 swxY w Y   dS )z¹Close all connections

        This method closes all connections. It returns the number
        of connections it closed.

        Used mostly for tests.

        Returns int.
        r   FrÍ   r   N)	r)   rº   Úqsizer&   Ú
disconnectr¸   rÝ   r   r   )r�   r½   Úcnxqr‡   s       r/   Ú_remove_connectionsz'MySQLConnectionPool._remove_connectionsT  sN  € õ "ð 	ð 	ØˆCØ”?ˆDØ—*’*‘,”,ð ð
ØŸ(š(¨˜(Ñ/Ô/�CØ—N’NÑ$Ô$Ð$Ø˜1‘H�C�CøÝ”{ð ð ð Ø�J�Jð	ð 	ð 	ð 	ñ 	ô 	ð 	ð 	õ !ð ð ð ØÝð ð ð à�Dðøøøð —*’*‘,”,ð ð ð!	ð 	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	ð 	ð 	s@   ˆB1§/AÁB1ÁBÁ(B1Á6BÂ	B1ÂBÂB1Â1B5Â8B5)r®   NT)
r"   rM   r    r¯   r°   ru   r   r   r   r‰   r¦   )r   rM   )r   ru   )r   r   r   r‰   )r"   rM   r   r‰   )r    r‚   r   r‰   )r‡   rˆ   r   r‰   rs   )r‡   rÔ   r   r‰   r¥   )r§   r¨   r©   rª   rŽ   r¬   r    r"   rŸ   r¼   rµ   r¶   rÓ   r    r,   rä   r$   rB   r/   r*   r*   Ž  sA  € € € € € Ø4Ð4ð Ø#'Ø#'ð	ð ð ð ð ð@ ðð ð ñ „Xðð ðð ð ñ „Xðð ð#ð #ð #ñ „Xð#ðWð Wð Wð Wð*$ð $ð $ð $ð$ð $ð $ð $ðPð Pð Pð Pð$ IMð-(ð -(ð -(ð -(ð -(ð^ 4ð  4ð  4ð  4ðDð ð ð ð ð rB   r*   )r   r   r   r   )r   r   r   r1   )re   r   r   r   r   r1   )r   r   r   r‚   )7rª   Ú
__future__r   r¸   rQ   ÚreÚ	threadingÚtypesr   Útypingr   r   r   r   r	   r
   r   Úuuidr   Údns.exceptionrw   Údns.resolverrv   r'   Úconnection_cextr   Ú
connectionr   Ú	constantsr   r   Úerrorsr   r   r   r   r   Úoptionfilesr   ÚRLockr)   rÆ   rÊ   ÚcompilerÈ   r(   r   Ú__annotations__r   r0   rd   rU   r%   r   r*   r$   rB   r/   ú<module>rõ      sô  ðð: <Ð ;Ð ;Ø "Ð "Ð "Ð "Ð "Ð "à €€€Ø €€€Ø 	€	€	€	Ø Ð Ð Ð à Ð Ð Ð Ð Ð Ø DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DØ Ð Ð Ð Ð Ð ðØÐÐÐØÐÐÐð €N€Nøð ð ð ð Ø€N€N€Nðøøøð
Ø1Ð1Ð1Ð1Ð1Ð1Ð1øØð ð ð ØÐÐÐðøøøð (Ð 'Ð 'Ð 'Ð 'Ð 'Ø ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;ðð ð ð ð ð ð ð ð ð ð ð ð ð ð +Ð *Ð *Ð *Ð *Ð *à&�y”Ñ(Ô(Ð ØÐ ØÐ Ø�R”ZÐ 7Ñ8Ô8Ð ØB€à'Ð/€O€O°oÐGWÐ5Xð ð ð ð ñ ð 57Ð Ð 6Ð 6Ð 6Ñ 6ðð ð ð ð:ZIð ZIð ZIð ZIðz_,ð _,ð _,ð _,ðDð ð ð ð0J(ð J(ð J(ð J(ð J(ñ J(ô J(ð J(ðZ`ð `ð `ð `ð `ñ `ô `ð `ð `ð `s#   ¹A ÁAÁAÁA ÁA#Á"A#