https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/trac/db/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/trac/db/__pycache__/pool.cpython-310.pyc
o

�k�`$�@s�ddlZddlZddlmZddlmZddlmZmZddl	m
Z
ddlmZddl
mZGdd	�d	e�ZGd
d�de�ZGdd
�d
e�Zeej�dd��Zee�ZGdd�de�ZdS)�N)�	TracError)�ConnectionWrapper)�
get_thread_id�	threading)�time_now)�exception_to_unicode)�_c@seZdZdZdS)�TimeoutErrorzjException raised by the connection pool when no connection has become
    available after a given timeout.N)�__name__�
__module__�__qualname__�__doc__�rr�./usr/lib/python3/dist-packages/trac/db/pool.pyr	sr	c@s*eZdZdZd	dd�Zdd�Zdd�ZdS)
�PooledConnectionz]A database connection that can be pooled. When closed, it gets returned
    to the pool.
    NcCs$t�|||�||_||_||_dS�N)r�__init__�_pool�_key�_tid)�self�pool�cnx�key�tid�logrrrr&s
zPooledConnection.__init__cCs4|jr|j}d|_d|_|j�||j|j�dSdSr)rrr�_return_cnxrr)rrrrr�close,s�zPooledConnection.closecCs|��dSr)r)rrrr�__del__3szPooledConnection.__del__r)r
rrr
rrrrrrrr!s

rc@s<eZdZdZdd�Zd
dd�Zdd�Zd	d
�Zd
dd�ZdS)�ConnectionPoolBackendz.A process-wide LRU-based connection pool.
    cCs8t�t���|_||_i|_g|_g|_g|_d|_	dS)Nr)
r�	Condition�RLock�
_available�_maxsize�_activer�	_pool_key�
_pool_time�_waiters)r�maxsizerrrr;s
zConnectionPoolBackend.__init__Nc
Cs�d}|�d�}t|�}t�}t�}|j�T||f|jvr*|j||f\}}	|	d7}	n,|jdkr7|�||||�}|sT|jd7_|j��|jd8_|�||||�}d}	|ra||	f|j||f<Wd�n1skwY|	dkoxt	|t
�}
d}|
r�|\}}z|dkr�|��n|dkr�|��|dvr�|j
di|��}Wn5ty�}
z
|
}d}WYd}
~
n$d}
~
wty�}
z|
}|r�|jd|dd	�d}WYd}
~
nd}
~
ww|�rt	|t
��s|
r�|j�||	f|j||f<Wd�n1s�wYt|||||�S|
�r-|j�|j||f=Wd�n	1�swY|dk�r-|�||�St	|t��r5|�t�|}td
|d�}t|�|�)
Nr�r�pingr)r�createzException caught on %sT)�exc_infoz:Unable to get database connection within %(time)d seconds.)�timer)�get�strrrr"r$r'�	_take_cnx�wait�
isinstance�tupler*r�get_connectionr�	Exception�errorr�get_cnxrr	)r�	connector�kwargs�timeoutrrr�startr�num�deferred�	exception�op�e�errmsgrrrr7Ds~



��
������

�
zConnectionPoolBackend.get_cnxcCs�||jvr(|j�|�}|j�|�|j�|�|j�|�}t|d�r&d|fS|St|j�t|j�|jkr7dSt|j�|jkrU|j�d�}|j�d�|j�d�d|fSdS)z<Note: _available lock must be held when calling this method.r*)r+NrrN)	r%�index�popr&r�hasattr�lenr$r#)rr8r9rr�idxrrrrr0�s 

�zConnectionPoolBackend._take_cnxcCs|j�0||f|jvs
J�|j||f\}}|dkr!|j||f=n||df|j||f<Wd�n1s6wY|dkr�z|��WntyT|��d}Ynw|j�&|rq|jrq|j�|�|j�|�|j	�t
��|j��Wd�dS1s�wYdSdS)Nr))r"r$�rollbackr5r�poolabler�appendr%r&r�notify)rrrrr<rrrr�s.���
"��z!ConnectionPoolBackend._return_cnxcCs�d}|durd}t�|}|j�e|dur+|j��D]
\}}t|t�s'|��qi|_|jr]|jd|krm|j�	d�}|��|j
�	d�|j�	d�|jre|jd|ks5Wd�dSWd�dSWd�dSWd�dS1sxwYdS)z,Close pooled connections not used in a while�xNr)rr"r$�valuesr2r3rr&rrCr%)rr�delay�when�dbr<rrr�shutdown�s0

�����"�zConnectionPoolBackend.shutdownr)	r
rrr
rr7r0rrPrrrrr8s
	Cr�TRAC_DB_POOL_SIZE�
c@s(eZdZdd�Zddd�Zddd�ZdS)	�ConnectionPoolcKs||_||_dSr)�
_connector�_kwargs)rr(r8r9rrrr�s
zConnectionPool.__init__NcCst�|j|j|�Sr)�_backendr7rTrU)rr:rrrr7�szConnectionPool.get_cnxcCst�|�dSr)rVrP)rrrrrrP�szConnectionPool.shutdownr)r
rrrr7rPrrrrrS�s
rS)�os�sys�	trac.corer�trac.db.utilr�trac.util.concurrencyrr�trac.util.datefmtr�trac.util.textr�trac.util.translationrr	r�objectr�int�environr.�
_pool_sizerVrSrrrr�<module>s

https://t.me/RX1948 - 2025