/var/opt/nydus/ops/mysql/connector/__pycache__
NameSizeModeActions
abstracts.cpython-312.pyc1263050644editdlrm
authentication.cpython-312.pyc148150644editdlrm
charsets.cpython-312.pyc102270644editdlrm
connection.cpython-312.pyc705380644editdlrm
connection_cext.cpython-312.pyc485700644editdlrm
constants.cpython-312.pyc482270644editdlrm
conversion.cpython-312.pyc315540644editdlrm
cursor.cpython-312.pyc587990644editdlrm
cursor_cext.cpython-312.pyc497900644editdlrm
custom_types.cpython-312.pyc13400644editdlrm
dbapi.cpython-312.pyc30230644editdlrm
errorcode.cpython-312.pyc907520644editdlrm
errors.cpython-312.pyc133090644editdlrm
logger.cpython-312.pyc3390644editdlrm
network.cpython-312.pyc319440644editdlrm
optionfiles.cpython-312.pyc145250644editdlrm
pooling.cpython-312.pyc273930644editdlrm
protocol.cpython-312.pyc471850644editdlrm
tls_ciphers.cpython-312.pyc78190644editdlrm
types.cpython-312.pyc25860644editdlrm
utils.cpython-312.pyc281810644editdlrm
version.cpython-312.pyc6900644editdlrm
_decorating.cpython-312.pyc39980644editdlrm
_scripting.cpython-312.pyc157000644editdlrm
__init__.cpython-312.pyc17090644editdlrm
Edit: /var/opt/nydus/ops/mysql/connector/__pycache__/pooling.cpython-312.pyc (27393B)
N jbUdZddlmZddlZddlZddlZddlZddlmZddl m Z m Z m Z m Z mZmZmZmZddlmZ ddlZddlZdZ d d lmZd d lmZd d lmZmZd d l m!Z!m"Z"m#Z#m$Z$m%Z%d dl&m'Z'e rd dl(m)Z)ejTZ+dZ,dZ-ej\dZ/dZ0eeneefZ1de2d<iZ3de2d<d dZ4 d!dZ5 d"dZ6d#dZ7GddZ8GddZ9y#e$rdZYwxYw#e$rdZYwxYw)$z5Implementing pooling of connections to MySQL servers.) annotationsN) TracebackType) TYPE_CHECKINGAnyDictNoReturnOptionalTupleTypeUnion)uuid4TF)CMySQLConnection)MySQLConnection) CNX_POOL_ARGSDEFAULT_CONFIGURATION)ErrorInterfaceErrorNotSupportedError PoolErrorProgrammingError)read_option_files)MySQLConnectionAbstract @z[^a-zA-Z0-9._:\-*$#]z0MySQL Connector/Python C Extension not availablezUnion[type, Tuple[type, ...]]MYSQL_CNX_CLASSzDict[str, MySQLConnectionPool]_CONNECTION_POOLSPooledMySQLConnectionc d|vr|dn td i|}|jddurtttt 5|t vrtd i|t |<nAtt |tr*t |j}d|vr|d|k7r tdddd t |jS#1swY!xYw#t$rtd|ddwxYw) z!Return a pooled MySQL connection. pool_nameuse_pureFN pool_sizez)Size can not be changed for active pools.z%Failed getting connection from pool '')generate_pool_namegetr ImportError ERROR_NO_CEXTCONNECTION_POOL_LOCKrMySQLConnectionPool isinstancer"rget_connectionAttributeErrorr)kwargsr check_sizes H/opt/nydus/tmp/pip-target-a90h98xg/lib/python/mysql/connector/pooling.py_get_pooled_connectionr1Ps +f4{:L:Vv:Vzz*&+;+C-((  - -+>+H+H i ( ))46I J*95??Jf$ )< )J KLL  +::<<   3I;a @  sAC)C C  C&c `|j} |d}|d=tgd}d}|D]}t|j |z }|r4t |dkDrdnd}d j |}td |d |t|d r|dz }|jd d |d <|d dks|d d kDrtd|d t|d trtd|d d|cxkrt |kr tdi} g} t|ddD]>}|d | vr|g| |d <| j|d (| |d j|@| D]} | | } tt | D]y} t | dz }t!j"d|}| j%|}|j}|j'||j%d d t)di|ccStd#t$r tddwxYw#t*$rYwxYw)aReturn 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) userpasswordhostport unix_socketdatabaser r"priorityrrsz, 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 r0z*_get_failover_connection..s:T)keyreversez,Unable to connect to any of the target hostsr$)copyKeyError ValueErrorsetkeyslenjoinhasattrr&rr+intrsortedappendrangerandomrandintpopupdateconnectr)r.configr3support_cnx_argspriority_countserverdiffarglstserver_directoryserver_priority_listr: failover_list_lastindex new_configs r0_get_failover_connectionrdms[[]FE*% z  N6;;=!$44 TQ#BC))D/C23%~cUK  6: & a N#ZZ C8z *  !VJ%7#%=  +,. &,c2 $Z013 %. >)CM)   *'>M * %5 54:8 VJ/ 0 ' 'z(: ; VJ/ 0 7 7 ? N)(2 s=)*A}%)DNN1d+E"&&u-FJ   f % NN:t , ,,,+) G HHU E9:DEL  sH+ H!H! H-,H-c^dvrjdnd}t|ts td|rts tddvr tddvr tdd vr td d vr t d d < t jjd d }g}|D]P}|j|jjd|j|j|j dR|j#d|Dcgc] }|d |ddc}d <dvrdd<jddvrt%di}t'di|Sd vr t)diS t+fdt,Dr t/diS j3dd}dvrd=|st4t7t8t4r |s t5|iSt;|iS#t jj$rtd d ddwxYwcc}w#t0$rYwxYw)aCreates or gets a MySQL connection object. In its simpliest form, `connect()` will open a connection to a MySQL server and return a `MySQLConnectionAbstract` subclass object such as `MySQLConnection` or `CMySQLConnection`. 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`. Args: *args: N/A. **kwargs: For a complete list of possible arguments, see [1]. If no arguments are given, it uses the already configured or default values. Returns: A `MySQLConnectionAbstract` subclass instance (such as `MySQLConnection` or `CMySQLConnection`) or a `PooledMySQLConnection` instance. Examples: A connection with the MySQL server can be established using either the `mysql.connector.connect()` method or a `MySQLConnectionAbstract` subclass: ``` >>> from mysql.connector import MySQLConnection, HAVE_CEXT >>> >>> cnx1 = mysql.connector.connect(user='joe', database='test') >>> cnx2 = MySQLConnection(user='joe', database='test') >>> >>> cnx3 = None >>> if HAVE_CEXT: >>> from mysql.connector import CMySQLConnection >>> cnx3 = CMySQLConnection(user='joe', database='test') ``` References: [1]: https://dev.mysql.com/doc/connector-python/en/connector-python-connectargs.html 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 documentationr8z. sQz]Qx[L$ArB)rC)r6r7read_default_file option_filesc3&K|]}|v ywNr$).0rCr.s r0 zconnect..4s6 sf} sr!r$)rSr+boolrHAVE_DNSPYTHONrdnsresolverquery exception DNSExceptionrOtargetto_textr7r:risortrrUrdanyrr1 NameErrorr&rr'r(r)argsr.rf srv_recordsr3srvrcr!s ` r0rUrUsR(1F':fjj#G gt $GHH 8  F " N  V  M    S   26:F6N ,,,,VF^UCK C OOJJ..d.CHH # !jj    A BBJ BJ3S[#f+ 6( z f$!'(;!<~ &'&00 $$$V'1&11 6 6 6)3F3 3 7zz*e,HV : ,4m, ,000 D +F ++g}}))  26&>2B!D  " *    s$#G'H5"H '1H H,+H,c g}dD] } |jt||"|s tddj |S#t$rYLwxYw)zGenerate 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. )r6r7r4r9z.Failed generating pool name; specify pool_namer`)rOstrrFrrK)r.partsrCs r0r%r%Fs` E3  LLVC[) *4 HII 88E?    sA AAcleZdZdZd dZd dZ d dZd dZddZe ddZ e ddZ y )raClass 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. Attributes: pool_name (str): Returns the name of the connection pool to which the connection belongs. ct|ts tdt|ts td||_||_y)zConstructor. Args: pool: A `MySQLConnectionPool` instance. cnx: A `MySQLConnectionAbstract` subclass instance. z$pool should be a MySQLConnectionPoolzcnx should be a MySQLConnectionN)r+r*r-r _cnx_pool_cnx)selfpoolcnxs r0__init__zPooledMySQLConnection.__init__qs?$ 34 !GH H#/ !BC C.2-0 rBc|Srnr$rs r0 __enter__zPooledMySQLConnection.__enter__s rBc$|jyrn)close)rexc_type exc_value tracebacks r0__exit__zPooledMySQLConnection.__exit__s rBc.t|j|S)z0Calls attributes of the MySQLConnection instance)getattrr)rattrs r0 __getattr__z!PooledMySQLConnection.__getattr__styy$''rBc |j}|jjr|j|jj|d|_y#|jjd|_wxYw)aDo not close, but adds connection back to pool. For a pooled connection, close() does not actually close it but returns it to the pool and makes it available for subsequent connection requests. If the pool configuration parameters are changed, a returned connection is closed and reopened with the new configuration before being returned from the pool again in response to a connection request. N)rr reset_sessionadd_connectionrrs r0rzPooledMySQLConnection.closes_ ))C~~++!!# NN ) )# .DI NN ) )# .DIs 2A$A;c td)zConfiguration is done through the pool. For pooled connections, the `config()` method raises a `PoolError` exception. Configuration for pooled connections should be done using the pool object. zKConfiguration for pooled connections should be done through the pool itself)r)r.s r0rVzPooledMySQLConnection.configs   rBc.|jjS)zHReturns the name of the connection pool to which the connection belongs.)rr rs r0r zPooledMySQLConnection.pool_names~~'''rBN)rr*rrreturnNonerr)rzType[BaseException]r BaseExceptionrrrr)rrrr)rr)r.rrrrr) __name__ __module__ __qualname____doc__rrrrr staticmethodrVpropertyr r$rBr0rr^sn$ 1%!!   ("    ((rBceZdZdZ d ddZeddZeddZeddZddZ ddZ dd Z dd Z ddd Z dd Zdd Zy)r*z*Class defining a pool of MySQL connectionsNc d|_d|_||_|j||j |xs t di|i|_tj|j|_ t|_ |rJ|jdi|d}||jkr&|j|dz }||jkr%yyy)aConstructor. 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. Args: pool_name: The pool name. If this argument is not given, Connector/Python automatically generates the name, composed from whichever of the host, port, user, and database connection arguments are given in kwargs, in that order. pool_size: The pool size. If this argument is not given, the default is 5. pool_reset_session: Whether to reset session variables when the connection is returned to the pool. **kwargs: Optional additional connection arguments, as described in [1]. Examples: ``` >>> dbconfig = { >>> "database": "test", >>> "user": "joe", >>> } >>> cnxpool = mysql.connector.pooling.MySQLConnectionPool(pool_name = "mypool", >>> pool_size = 3, >>> **dbconfig) ``` References: [1]: https://dev.mysql.com/doc/connector-python/en/connector-python-connectargs.html Nrrr$) _pool_size _pool_name_reset_session_set_pool_size_set_pool_namer% _cnx_configqueueQueue _cnx_queuer _config_version set_configr)rr"r pool_reset_sessionr.cnts r0rzMySQLConnectionPool.__init__sL*.)-0 I& IE);)Ef)EF+-@E OOA  %w  DOO %f %C'##%q' rBc|jS)z(Returns the name of the connection pool.)rrs r0r zMySQLConnectionPool.pool_namerBc|jS)z2Returns number of connections managed by the pool.)rrs r0r"zMySQLConnectionPool.pool_sizerrBc|jS)z!Returns whether to reset session.)rrs r0rz!MySQLConnectionPool.reset_sessions"""rBc |syt5 t}|jdi|||_t |_ dddy#t $r}td||d}~wwxYw#1swYyxYw)aSet the connection configuration for `MySQLConnectionAbstract` subclass instances. This method sets the configuration used for creating `MySQLConnectionAbstract` subclass instances such as `MySQLConnection`. See [1] for valid connection arguments. Args: **kwargs: Connection arguments - for a complete list of possible arguments, see [1]. Raises: PoolError: When a connection argument is not valid, missing or not supported by `MySQLConnectionAbstract`. References: [1]: https://dev.mysql.com/doc/connector-python/en/connector-python-connectargs.html Nz$Connection configuration not valid: r$)r)rUrVrr rr-r)rr.test_cnxerrs r0rzMySQLConnectionPool.set_configsx$  ! W"9)&)#) ',w$ " ! " W"Fse LMSVV W " !s(A(2A A%A  A%%A((A1cR|dks |tkDrtdt||_y)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)rr"s r0rz"MySQLConnectionPool._set_pool_sizes7 >Y)99 J#$& $rBctj|rtd|dt|tkDrtd|d||_y)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. z Pool name 'z' contains illegal charactersz ' is too longN)CNX_POOL_NAMEREGEXsearchr-rJCNX_POOL_MAXNAMESIZEr)rr s r0rz"MySQLConnectionPool._set_pool_name)sO  $ $Y / ;yk9V!WX X y>0 0 ;yk!GH H#rBct|ts td |jj |dy#t j $r}td|d}~wwxYw)zPut 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. ;Connection instance not subclass of MySQLConnectionAbstractFblock'Failed adding connection; queue is fullN)r+rrrputrFullrrrs r0_queue_connectionz%MySQLConnectionPool._queue_connection7s_#/M  P OO  5  1zz PEFC O Ps;A AAct5|js td|jj r td|s]t di|j} |j r)|jdr|jdkr td|j|_ nt|ts td|j|dddy#t$rYRwxYw#1swYyxYw) aAdds 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. Args: cnx: The `MySQLConnectionAbstract` subclass object to be added to the pool. If this argument is missing (aka `None`), the pool creates a new connection and adds it. 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 availablercompress)z^Pool reset session is not supported with compression for MySQL server version 5.7.2 or earlierrNr$)r)rrrfullrUrserver_versionrrFrpool_config_versionr+rrrs r0rz"MySQLConnectionPool.add_connectionJs&"## HII##% IJJ1 0 01 ++ ,,Z8..:/)+/*>*>'!#7#U  " "3 '=" !( )" !s0AC'5C>C' C$!C'#C$$C''C0ct5 |jjd}|j r|j|jk7r>|jdi|j |j|j|_t||cdddS#tj$r}t d|d}~wwxYw#t$r|j|wxYw#1swYyxYw)aGets 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. Returns: A `PooledMySQLConnection` instance. Raises: PoolError: On errors. Frz)Failed getting connection; pool exhaustedNr$)r)rr&rEmptyr is_connectedrrrVr reconnectrrrrs r0r,z"MySQLConnectionPool.get_connection}s" Voo)))6 $$&''3+B+BB .T--.MMO +/*>*>'(s3'" !;; V KLRUU V&**3/" !sFC'B!AC'+C;C'!C4 CCC'C$$C''C0cZt5d}|j}|jr9 |jd}|j |dz }|jr9|cdddS#t j $r|cYcdddSt$rt$rYOwxYw#1swYyxYw)zClose all connections This method closes all connections. It returns the number of connections it closed. Used mostly for tests. Returns int. rFrrN) r)rqsizer& disconnectrrrr)rrcnxqrs r0_remove_connectionsz'MySQLConnectionPool._remove_connectionss"C??D**, (((/CNN$1HC **,!" !{{J" !!" !s@B!'A*B!B!*B?B! BB!BB!!B*)rNT) r"rMr z Optional[str]rrqr.rrrr)rrM)rrq)r.rrr)r"rMrr)r rrr)rrrrrn)rz!Optional[MySQLConnectionAbstract]rrr)rrrrrrr r"rrrrrrr,rr$rBr0r*r*s4#'#' 66!6! 6  6  6p##W< $ $P&1(f"4HrBr*)r.rrr)r.rr5Union[PooledMySQLConnection, MySQLConnectionAbstract])r}rr.rrr)r.rrr):r __future__rrrQre threadingtypesrtypingrrrrr r r r uuidr dns.exceptionrs dns.resolverrrr'connection_cextr connectionr constantsrrerrorsrrrrr optionfilesr abstractsrRLockr)rrcompilerr(r__annotations__rr1rdrUr%rr*r$rBr0rsJ:<" SSSN1(;+2&y(RZZ 78B '/OoGW5X.5716:ZIZI:ZIzy, y,y,:y,x0Q(Q(hIIM Ns#C"C/"C,+C,/C98C9