/var/opt/nydus/ops/mysql/connector/aio/__pycache__
NameSizeModeActions
abstracts.cpython-312.pyc1155400644editdlrm
authentication.cpython-312.pyc131520644editdlrm
charsets.cpython-312.pyc173430644editdlrm
connection.cpython-312.pyc708760644editdlrm
cursor.cpython-312.pyc601950644editdlrm
logger.cpython-312.pyc3510644editdlrm
network.cpython-312.pyc305960644editdlrm
pooling.cpython-312.pyc302760644editdlrm
protocol.cpython-312.pyc115140644editdlrm
utils.cpython-312.pyc59830644editdlrm
_decorating.cpython-312.pyc43120644editdlrm
__init__.cpython-312.pyc4930644editdlrm
Edit: /var/opt/nydus/ops/mysql/connector/aio/__pycache__/pooling.cpython-312.pyc (30276B)
N jMeUdZddlmZddlZddlZddlZddlZddlZddlm Z ddl m Z m Z m Z mZmZmZmZmZddlmZmZddlmZ ddlZddlZdZd d lmZmZm Z m!Z!m"Z"d d l#m$Z$m%Z%m&Z&d dl'm(Z(e rd dl)m*Z*ejVZ,dZ-dZ.ej^dZ0e(fZ1de2d<iZ3de2d<ddZ4 d dZ5 d!dZ6d"dZ7GddZ8GddZ9y#e$rd ZYwxYw)#z5Implementing pooling of connections to MySQL servers.) annotationsN) TracebackType) TYPE_CHECKINGAnyDictNoReturnOptionalTupleTypeUnion)UUIDuuid4) CNX_POOL_ARGSTF)ErrorInterfaceErrorNotSupportedError PoolErrorProgrammingError)DEFAULT_CONFIGURATIONgenerate_pool_nameread_option_files)MySQLConnection)MySQLConnectionAbstract @z[^a-zA-Z0-9._:\-*$#]zUnion[type, Tuple[type, ...]]MYSQL_CNX_CLASSzDict[str, MySQLConnectionPool]_CONNECTION_POOLSPooledMySQLConnectioncKd|vr|dn tdi|}|tvrLtdi|}|jd{t4d{|t|<dddd{nAt t|tr*t|j }d|vr|d|k7r td t|jd{S777j#1d{7swY8xYw7#t$rtd|ddwxYww)z!Return a pooled MySQL connection. pool_nameN pool_sizez)Size can not be changed for active pools.z%Failed getting connection from pool '') rrMySQLConnectionPoolinitialize_poolCONNECTION_POOL_LOCK isinstancer#rget_connectionAttributeErrorr)kwargsr"pool check_sizes L/opt/nydus/tmp/pip-target-a90h98xg/lib/python/mysql/connector/aio/pooling.py_get_pooled_connectionr0Ls +f4{:L:Vv:V ))",V,""$$$''+/ i (('' %i02E F&y1;; & VK%8J%FGH H&y1@@BBB %'''''C 3I;a @  s;DC D C D C D%C&AD-C)C'C) DDDC$C C$ D'C))DDcjK|j} |d}|d=hd}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]} t | dz }t!j"d|}| j%|}|j}|j'||j%d d t)di|d{ccStd#t$r tddwxYw7/#t*$rYwxYww)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> hostportuserdatabasepasswordpriorityr"r# unix_socketrrsz, z Unsupported connection argument z in failover: r8dz9Priority 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)Nr8r%xs r/z*_get_failover_connection..s:T)keyreversez,Unable to connect to any of the target hostsr%)copyKeyError ValueErrorsetkeyslenjoinhasattrgetrr)intrsortedappendrangerandomrandintpopupdateconnectr)r,configr2support_cnx_argspriority_countserverdiffarglstserver_directoryserver_priority_listr8 failover_list_lastindex new_configs r/_get_failover_connectionrdis[[]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 , $2z222+) G HHQ E9:DEF3  sYH3H B:H3DH3$H$2H"3H$6H3 HH3"H$$ H0-H3/H00H3czKdvrjdnd}t|ts td|rts tddvr tddvr tdd vr td d vr t d d < t jjd d d {}g}|D]P}|j|jjd|j|j|j dR|j#d|Dcgc] }|d |ddc}d <d vrt%did {S t'fdt(Drt+did {S dvrdd<jddvrt/di}t1di|d {Sdvrd=t3|i}|j1d {|S7:#t jj$rtdd dd wxYwcc}w77#t,$rYwxYw77Ww)aCreates 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`. 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 a `PooledMySQLConnection` instance. Raises: `mysql.connector.errors.NotSupportedError`: if pooled connection is not supported for the Python version and OS that are being used. Examples: A connection with the MySQL server can be established using either the `mysql.connector.aio.connect()` method or a `MySQLConnectionAbstract` subclass: ``` >>> from mysql.connector.aio import MySQLConnection >>> >>> cnx1 = await mysql.connector.aio.connect(user='joe', database='test') >>> cnx2 = MySQLConnection(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 documentationr9zs r/r@zconnect..sQz]Qx[L$ArA)rB)r3r4c3&K|]}|v ywNr%).0rBr,s r/ zconnect.. s6 sf} sread_default_file option_filesuse_purer%)rSr)boolrHAVE_DNSPYTHONrdns asyncresolverquery exception DNSExceptionrOtargetto_textr4r8risortrdanyrr0 NameErrorrrUr)argsr,rf srv_recordsr2srvrccnxs ` r/rUrUsH(1F':fjj#G gt $GHH 8  F " N  V  M    S   26:F6N  # 1 1 7 7v NNK C OOJJ..d.CHH # !jj    A BBJ BJ3S[#f+ 6( z V-7777 6 6 6/9&99 9 7f$!'(;!<~ &'&00 *z***V :  4 *6 *C ++- JaO}}))  26&>2B!D  " 8 :    + sBH;&G+.G(/G+3A.H;!H3H; H$ H;&H(7H&8H(;>> dbconfig = { >>> "database": "test", >>> "user": "joe", >>> } >>> # initialize the MySQLConnectionPool instance >>> cnxpool = mysql.connector.aio.pooling.MySQLConnectionPool( >>> pool_name = "mypool", >>> pool_size = 3, >>> ) >>> # Open up the pool of connections >>> await cnxpool.initialize_pool(**dbconfig) >>> # cnxpool is ready to be used ... ``` References: [1]: https://dev.mysql.com/doc/connector-python/en/connector-python-connectargs.html N) r _pool_size _pool_name_reset_session_set_pool_size_set_pool_name _cnx_configasyncioQueue _cnx_queuer_config_version)rr#r"pool_reset_sessionr,s r/rzMySQLConnectionPool.__init__slX )-)-$6 I&     *+1BI-- OOC &+WrAcK|jsCt4d{|jtdi|jdddd{|jrd|j di|jd{d}||j kr.|jd{|dz }||j kr-yyy77w#1d{7swYxYw7^77w)aOpens the connection pool and fill with MySQL database connections. This coroutine must be called after initializing an instance of MySQLConnectionPool to make the build the pool of connections and make the instance ready to be used. Args: **kwargs: Connection arguments, as described in [1]. References: [1]: https://dev.mysql.com/doc/connector-python/en/connector-python-connectargs.html Nrrr%)rr(rrr set_configrr)rcnts r/r'z#MySQLConnectionPool.initialize_pools++##$6$J9I9I$JK,+   !$//5D$4$45 5 5C'))+++q' ,++++ 6,shC CC %C C  C/C =C>(C &C'C C C C C CC C c|jS)z(Returns the name of the connection pool.)rrs r/r"zMySQLConnectionPool.pool_namerAc|jS)z2Returns number of connections managed by the pool.)rrs r/r#zMySQLConnectionPool.pool_sizerrAc|jS)z!Returns whether to reset session.)rrs r/rz%MySQLConnectionPool.can_reset_sessions"""rAcNK|sy tdi|d{}|jd{t4d{||_t |_dddd{y7R7<7/7 #1d{7swYyxYw#t $r}td||d}~wwxYww)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%)rU disconnectr(rrr Exceptionr)rr,rerrs r/rzMySQLConnectionPool.set_configs  S)&))C.." " "++#) ',w$,++* "+++++ SB3%HIs R SsB%BA(BA*BA,BA0 B"A.#B'B%(B*B,B.B0B6A9 7B>BB%B B"BB""B%cR|dks |tkDrtdt||_y)zSet 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 r/rz"MySQLConnectionPool._set_pool_sizes7 >Y)99 J#$& $rActj|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+rICNX_POOL_MAXNAMESIZEr)rr"s r/rz"MySQLConnectionPool._set_pool_namesO  $ $Y / ;yk9V!WX X y>0 0 ;yk!GH H#rAct|ts td |jj |y#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 MySQLConnectionAbstract'Failed adding connection; queue is fullN)r)rrr put_nowaitr QueueFullrrrs r/_queue_connectionz%MySQLConnectionPool._queue_connection's\#/M  P OO & &s +   PEFC O Ps9A AAcK|js td|jjr td|sit di|jd{} |j r-|jdr|j dkr td|j|_ nt|ts td|j|y7}#t$rYLwxYww) 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 availablerNcompress)rz^Pool reset session is not supported with compression for MySQL server version 5.7.2 or earlierrr%)rrrfullrUrget_server_versionrrErpool_config_versionr)rrrs r/rz"MySQLConnectionPool.add_connection8s$DE E ??   !EF F3$"2"233C ''((4..09<+%'+&:&:C #c?3Q s#-4  s7AC(CC(9CAC( C%"C($C%%C(cK |jj}|j d{r|j |jk7rF |jdi|j|jd{|j |_t||S#tj$r}t d|d}~wwxYw77J#t$r|j|wxYww)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. z)Failed getting connection; pool exhaustedNr%)r get_nowaitr QueueEmptyrrrr_set_connection_optionsr reconnectrrr rs r/r*z"MySQLConnectionPool.get_connectionis R//,,.C &&(((##s'>'>> +++?d.>.>?mmo%%'+&:&:C #$T3//!! RGHc Q R) &! &&s+ s[C+B!C+CC+/C ?C C C+!C4 CCC+ C C((C+c(Kd}|j}|jr? |j}|jd{|dz }|jr?|S7#tj $r|cYSt $rt$rY?wxYww)a$Close all connections This method closes all connections and returns the number of connections it closed. This method should be used internally while cleaning-up the connection pool by closing each and every active connection objects currently residing in the pool. Returns: An integer defining the number of open connections closed during clean-up. Raises: PoolError: On errors while fetching connections from the pool or while disconnecting an open connection. rNr)rqsizerrrrrr)rrcnxqrs r/_remove_connectionsz'MySQLConnectionPool._remove_connectionssjjl oo'nn&&&q jjl '%%     sLB#A$A" A$B B"A$$B9B;B BBBc>K|jd{S7w)aCleans up the connection pool This public method gracefully shuts down the connection pool by disconnecting all of the open connections currently active in the pool. Returns: An integer defining the number of open connections closed while shutting down the pool. Raises: PoolError: On errors while fetching connections from the pool or while disconnecting an open connection. N)rrs r/ close_poolzMySQLConnectionPool.close_pools--////s )rNT) r#rMr"z Optional[str]rrrr,rrrrr)rrM)rrr)r,rrr)r#rMrr)r"rrr)rrrrrl)rz!Optional[MySQLConnectionAbstract]rrr)rrrrrr'rr"r#rrrrrrr*rrr%rAr/r&r&s4#'#' 8-8-!8-! 8-  8-  8-t,##S6 $ $P$8</$4/$ /$b0>: 0rAr&)r,rrr )r,rr5Union[PooledMySQLConnection, MySQLConnectionAbstract])r~rr,rrrr):r __future__rrrrQrertypesrtypingrrrrr r r r uuidr rmysql.connector.constantsrdns.asyncresolverrt dns.exceptionrs ImportErrorerrorsrrrrrpoolingrrr connectionr abstractsrLockr(rrcompilerr__annotations__rr0rdrUrr r&r%rAr/rs:<" SSS3NSR'2$w||~RZZ 782A1C.C4616:XIXI:XIvp pp:pf L(L(^_0_0C NsCC&%C&