HEX
Server: Microsoft-IIS/10.0
System: Windows NT ITPWINWEBSVR22 10.0 build 20348 (Windows Server 2022) AMD64
User: www.conferencesearch.co.uk (0)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: D:/Python311/Lib/site-packages/mysql/connector/__pycache__/pooling.cpython-311.pyc
�

�nc�O���dZddlZddlZddlZddlZddlmZ	ddlZddl	ZdZ
n
#e$rdZ
YnwxYw	ddlm
Z
n
#e$rdZ
YnwxYwddlmZdd	lmZmZdd
lmZmZmZmZmZddlmZej��ZdZd
Zejd��Z dZ!e
�enee
fZ"iZ#d�Z$d�Z%d�Z&d�Z'Gd�d��Z(Gd�d��Z)dS)z5Implementing pooling of connections to MySQL servers.�N)�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 availablec�6�d|vr|dntd	i|��}|�d��durt�tt���t
5|tvrtd	i|��t|<nQtt|t��r1t|j	}d|vr|d|krtd���ddd��n#1swxYwY	t|���S#t$rtd|�d���d�wxYw)
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_LOCK�_CONNECTION_POOLS�MySQLConnectionPool�
isinstancerr�get_connection�AttributeErrorr
)�kwargsr�
check_sizes   �9D:\Python311\Lib\site-packages\mysql/connector/pooling.py�_get_pooled_connectionr$Js��� +�f�4�V��{���:L�:V�:V�v�:V�:V���z�z�*����&�)�+;�)��-�(�(�(�
�M�M��-�-�	M�+>�+H�+H��+H�+H��i�(�(�
�)�)�4�6I�
J�
J�	M�*�9�5�?�J��f�$�
M���)<�
�)J�
M�� 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�9Dc�~�|���}	|d}n#t$rtd��d�wxYw|d=tgd���}d}|D]�}t|�����|z
}|rAt|��dkrdnd}d	�|��}td
|�d|�����t|d��r|dz
}|�dd
��|d<|ddks|dd
krtd|d�����t|dt��std|d�������d|cxkrt|��krnntd���i}	g}
t|d�d���D]U}|d|	vr(|g|	|d<|
�|d���4|	|d�|���V|
D]�}|	|}tt|����D]�}
t|��dz
}t!jd|��}|�|��}|���}|�|��|�dd��	t)di|��ccS#t*$rY��wxYw��td���)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.
    �failoverzfailover argument not providedN)	�user�password�host�port�unix_socket�databaserr�priorityrr�s�z, z Unsupported connection argument z in failover: r-�dz9Priority 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��|dS)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�hasattrrr
r�intr
�sorted�append�range�random�randint�pop�update�connectr	)r!�configr&�support_cnx_args�priority_count�server�diff�arg�lst�server_directory�server_priority_listr-�
failover_list�_�last�index�
new_configs                 r#�_get_failover_connectionrWgs����[�[�]�]�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�	@�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,c���d�vr��d��nd}t|t��std���|�r,tstd���d�vrtd���d�vrtd���d	�vrtd
���d�vrt
d�d<	tj��dd��}n2#tj	j
$rtd
�d�d���d�wxYwg}|D]D}|�|j�
d���|j|j|jd����E|�d����d�|D���d	<d�vr �d�d<��d��d�vrt%di���}t'di|��Sd	�vrt)di���S	t+�fd�t,D����rt/di���Sn#t0$rYnwxYw��dd��}d�vr �d=|st4�t7t8���t4r|st5|i���St;|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 documentationr+z<Using Unix domain sockets with DNS SRV lookup is not allowedr*z;Specifying a port number with DNS SRV lookup is not allowedr&zASpecifying multiple hostnames with DNS SRV look up is not allowedr)�SRVz Unable to locate any hosts for 'rNT)�omit_final_dot)r)r*r-�weightc�$�|d|dfS)Nr-r\rr2s r#r4zconnect.<locals>.<lambda>�s��Q�z�]�Q�x�[�L�$A�r5)r6c�0�g|]}|d|dd���S)r)r*)r)r*r)�.0�srvs  r#�
<listcomp>zconnect.<locals>.<listcomp>�s5��
�
�
�;>�S��[�#�f�+�6�6�
�
�
r5�read_default_file�option_filesc3� �K�|]}|�vV��	dS�Nr)r_r6r!s  �r#�	<genexpr>zconnect.<locals>.<genexpr>s'�����6�6��s�f�}�6�6�6�6�6�6r5rr)rFr�boolr
�HAVE_DNSPYTHONr�dns�resolver�query�	exception�DNSExceptionrB�target�to_textr*r-r\�sortrrHrW�anyrr$�	NameErrorrrrrr)�argsr!rY�srv_recordsr&r`rVrs `      r#rHrH�sf���(1�F�':�E�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��2�'�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��-��:���	-�,�	-��m�,�,�,��1��1���0��0�0�0��D�+�F�+�+�+s�(&C�/C>�+G.�.
G;�:G;c���g}dD];}	|�t||�����,#t$rY�8wxYw|std���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.
    )r)r*r'r,z.Failed generating pool name; specify pool_namerS)rB�strr9rr>)r!�partsr6s   r#rr"s���
�E�3����	��L�L��V�C�[�)�)�*�*�*�*���	�	�	��D�	�����J��H�I�I�I��8�8�E�?�?�s�(1�
>�>c�\�eZdZdZd�Zd�Zd�Zd�Zd�Ze	d���Z
ed���Zd	S)
�PooledMySQLConnectionaClass 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.
    c��t|t��std���t|t��std���||_||_dS)z�Initialize

        The pool argument must be an instance of MySQLConnectionPoll. cnx
        if an instance of MySQLConnection.
        z$pool should be a MySQLConnectionPoolzcnx should be a MySQLConnectionN)rrr �MYSQL_CNX_CLASS�	_cnx_pool�_cnx)�self�pool�cnxs   r#�__init__zPooledMySQLConnection.__init__Is[���$� 3�4�4�	I� �!G�H�H�H��#��/�/�	D� �!B�C�C�C������	�	�	r5c��|Srer�r~s r#�	__enter__zPooledMySQLConnection.__enter__Vs���r5c�.�|���dSre)�close)r~�exc_type�	exc_value�	tracebacks    r#�__exit__zPooledMySQLConnection.__exit__Ys���
�
�����r5c�,�t|j|��S)z0Calls attributes of the MySQLConnection instance)�getattrr})r~�attrs  r#�__getattr__z!PooledMySQLConnection.__getattr__\s���t�y�$�'�'�'r5c���	|j}|jjr|���|j�|��d|_dS#|j�|��d|_wxYw)aYDo 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�zPooledMySQLConnection.close`sz��	��)�C��~�+�
$��!�!�#�#�#��N�)�)�#�.�.�.��D�I�I�I��
�N�)�)�#�.�.�.��D�I����s�'A�#A/c� �td���)z&Configuration is done through the poolzKConfiguration for pooled connections should be done through the pool itself)r)r!s r#rIzPooledMySQLConnection.configrs���
�
�
�	
r5c��|jjS�z&Return the name of the connection pool)r|rr�s r#rzPooledMySQLConnection.pool_namezs���~�'�'r5N)
�__name__�
__module__�__qualname__�__doc__r�r�r�r�r��staticmethodrI�propertyrrr5r#ryry:s������������������(�(�(����$�
�
��\�
��(�(��X�(�(�(r5ryc��eZdZdZdd�Zed���Zed���Zed���Zd	�Z	d
�Z
d�Zd�Zdd
�Z
d�Zd�ZdS)rz*Class defining a pool of MySQL connections�NTc��d|_d|_||_|�|��|�|ptdi|����i|_tj|j��|_	t��|_|r@|jdi|��d}||jkr(|�
��|dz
}||jk�$dSdSdS)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.
        Nrrr)�
_pool_size�
_pool_name�_reset_session�_set_pool_size�_set_pool_namer�_cnx_config�queue�Queue�
_cnx_queuer�_config_version�
set_configr�)r~rr�pool_reset_sessionr!�cnts      r#r�zMySQLConnectionPool.__init__�s���������0������I�&�&�&����I�E�);�)E�)E�f�)E�)E�F�F�F�����+�d�o�6�6���$�w�w����	��D�O�%�%�f�%�%�%��C����'�
��#�#�%�%�%��q������'�
�
�
�	�	�
�
r5c��|jSr�)r�r�s r#rzMySQLConnectionPool.pool_name������r5c��|jS)z0Return number of connections managed by the pool)r�r�s r#rzMySQLConnectionPool.pool_size�r�r5c��|jS)zReturn whether to reset session)r�r�s r#r�z!MySQLConnectionPool.reset_session�s
���"�"r5c��|sdSt5	t��}|jdi|��||_t	��|_n%#t$r}td|����|�d}~wwxYw	ddd��dS#1swxYwYdS)aTSet 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)rrHrIr�rr�r r)r~r!�test_cnx�errs    r#r�zMySQLConnectionPool.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�	Ws4�A7�5A�A7�
A&�A!�!A&�&A7�7A;�>A;c�d�|dks|tkrtdt�����||_dS)aSet 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.
        rz8Pool size should be higher than 0 and lower or equal to N)�CNX_POOL_MAXSIZEr r�)r~rs  r#r�z"MySQLConnectionPool._set_pool_size�sN����>�	�Y�)9�9�	� �&�#�&�&���
�$����r5c���t�|��rtd|�d����t|��tkrtd|�d����||_dS)aSet 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.
        zPool name 'z' contains illegal charactersz
' is too longN)�CNX_POOL_NAMEREGEX�searchr r=�CNX_POOL_MAXNAMESIZEr�)r~rs  r#r�z"MySQLConnectionPool._set_pool_name�so���$�$�Y�/�/�	Y� �!W�y�!W�!W�!W�X�X�X��y�>�>�0�0�	I� �!G�y�!G�!G�!G�H�H�H�#����r5c���t|t��std���	|j�|d���dS#t
j$r}td��|�d}~wwxYw)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)rr{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(c��t5|jstd���|j���rtd���|sktdi|j��}	|jr4|jdr'|���dkrtd���n#t$rYnwxYw|j
|_n$t|t��std���|�|��ddd��dS#1swxYwYdS)	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)rr�rr��fullrHr��get_server_versionrr9r��pool_config_versionrr{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�@�	�
0�)������
 �����D�����+/�*>��'�'�!�#��7�7��#�M����
�"�"�3�'�'�'�=	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(�	(�	(s7�AC:�;B�C:�
B$�!C:�#B$�$A	C:�:C>�C>c���t5	|j�d���}n'#tj$r}td��|�d}~wwxYw|���r|j|jkrX|j	di|j
��	|���n$#t$r|�
|���wxYw|j|_t||��cddd��S#1swxYwYdS)awGet 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)rr�rr��Emptyr�is_connectedr�r�rIr��	reconnectr
r�ryr�s   r#rz"MySQLConnectionPool.get_connectionsk��"�	4�	4�
V��o�)�)��)�6�6�����;�
V�
V�
V�� K�L�L�RU�U�����
V�����$�$�&�&�
?��'�3�+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�|�t5d}|j}|���r}	|�d���}|���|dz
}n8#t
j$r|cYcddd��St$r�t$rYnwxYw|����}|cddd��S#1swxYwYdS)z�Close all connections

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

        Used mostly for tests.

        Returns int.
        rFr�rN)	rr��qsizer�
disconnectr�r�rr	)r~r��cnxqr�s    r#�_remove_connectionsz'MySQLConnectionPool._remove_connections<sN��"�	�	��C��?�D��*�*�,�,�
�
��(�(��(�/�/�C��N�N�$�$�$��1�H�C�C���{�����J�J�	�	�	�	�	�	�	�	�!����������D������*�*�,�,�
��!	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s@�B1�/A�B1�B�(B1�6B�	B1�B�B1�1B5�8B5)r�NTre)r�r�r�r�r�r�rrr�r�r�r�r�r�rr�rr5r#rr�s�������4�4�����0����X������X���#�#��X�#�W�W�W�*
$�
$�
$�$�$�$�P�P�P�"+(�+(�+(�+(�Z 4� 4� 4�D����r5r)*r�r�rD�re�	threading�uuidr�
dns.exceptionri�dns.resolverrhr�connection_cextr�
connectionr�	constantsrr�errorsr	r
rrr
�optionfilesr�RLockrr�r��compiler�rr{rr$rWrHrryrrr5r#�<module>r�s`��:<�;�����
�
�
�
�	�	�	�	���������������������N�N�������N�N�N�����
�1�1�1�1�1�1�1��������������(�'�'�'�'�'�;�;�;�;�;�;�;�;���������������+�*�*�*�*�*�&�y��(�(�������R�Z� 7�8�8��B�
�'�X�O�O�o�GW�5X�������:XI�XI�XI�v],�],�],�@���0C(�C(�C(�C(�C(�C(�C(�C(�LV�V�V�V�V�V�V�V�V�Vs�%�/�/�:�A�A