
    gi                        d Z ddlmZ ddlZddlmZmZ ddlmZ ddl	m
Z
 ddlmZmZmZ dd	lmZmZ dd
lmZmZ ddlmZ ddlmZ ddlmZ  ej        d          Z G d deee                   ZdS )z5
Psycopg null connection pool module (sync version).
    )annotationsN)Anycast)
Connection)TransactionStatus   )CTConnectFailedCBConnectionCB)AddConnectionConnectionPool)PoolTimeoutTooManyRequests)ConnectionTimeout)Event)_BaseNullConnectionPoolzpsycopg.poolc                       e Zd Z	 d3 ede          ddddddddddddddd	d
d4 fd%Zd5d6d(Zd7d+Zd8d/Zd9d:d0Z	d;d1Z
d<d2Z xZS )=NullConnectionPool type[CT]Nr         >@g      @g     @g     r@   )connection_classkwargsmin_sizemax_sizeopen	configurecheckresetnametimeoutmax_waitingmax_lifetimemax_idlereconnect_timeoutreconnect_failednum_workersconninfostrr   r   dict[str, Any] | Noner   intr   
int | Noner   bool | Noner   ConnectionCB[CT] | Noner   r    r!   
str | Noner"   floatr#   r$   r%   r&   r'   ConnectFailedCB | Noner(   c               j    t                                          ||||||	||||
||||||           d S )N)r   r   r   r   r    r   r   r   r!   r"   r#   r$   r%   r&   r(   )super__init__)selfr)   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   	__class__s                     f/var/www/html/Pagina-Ingenieria-Requisitos/venv/lib/python3.11/site-packages/psycopg_pool/null_pool.pyr5   zNullConnectionPool.__init__   s`    , 	-#%/#! 	 	
 	
 	
 	
 	
    returnNonec                H   |                                   | j        5  | j        rJ t                      | _        ddd           n# 1 swxY w Y   t                              d| j                   |                     t          |                      | j        	                    |          s'| 
                                 t          d| d          | j        5  | j        sJ d| _        ddd           n# 1 swxY w Y   t                              d| j                   dS )a9  
        Create a connection for test.

        Calling this function will verify that the connectivity with the
        database works as expected. However the connection will not be stored
        in the pool.

        Close the pool, and raise `PoolTimeout`, if not ready within *timeout*
        sec.
        Nz"waiting for pool %r initializationz%pool initialization incomplete after z seczpool %r is ready to use)_check_open_getconn_lock_pool_full_eventr   loggerinfor!   run_taskr   waitcloser   )r6   r"   s     r8   rC   zNullConnectionPool.waitG   s    	  """Z 	, 	,,,,,$)GGD!	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	8$)DDDmD))***$))'22 	UJJLLLSgSSSTTTZ 	) 	)(((($(D!	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	-ty99999s#   AA	A	C77C;>C;float | None	CT | Nonec                   ||dk    rt                      d }| j        dk    s| j        | j        k     rX	 |                     |          }n/# t          $ r"}t          t          |                    d d }~ww xY w| xj        dz  c_        no| j        rht          | j                  | j        k    rK| j	        | j
        xx         dz  cc<   t          d| j        ddt          | j                   dz             |S )	Ng        r   )r"   r   z	the pool z has already z requests waiting)r   r   _nconns_connectr   r*   r#   len_waiting_stats_REQUESTS_ERRORSr   r!   )r6   r"   connexs       r8   _get_ready_connectionz(NullConnectionPool._get_ready_connectiond   s$   7c>>--=A!=!=5}}W}55$ 5 5 5!#b''**45LLALLL 	#dm"4"48H"H"HK-...!3...!5DI555;c$-((;;;<   s   A 
A8A33A8rO   r	   boolc                >   | j         5  | j        s| j        r	 d d d            dS d |_        |j        j        t          j        k    r| j        | j	        xx         dz  cc<   |
                                 | xj        dz  c_        	 d d d            dS # 1 swxY w Y   d S )NFr   T)r>   _closedrL   _poolpgconntransaction_statusr   UNKNOWNrM   _RETURNS_BADrD   rI   r6   rO   s     r8   _maybe_close_connectionz*NullConnectionPool._maybe_close_connectionx   s    Z 		 		< DM 		 		 		 		 		 		 		 		 DJ{-1B1JJJD-...!3...JJLLLLLALL		 		 		 		 		 		 		 		 		 		 		 		 		 		 		 		 		 		s   BA BBBc                    |                      ||          \  }}t                              d| j        ||           | j        5  || _        || _        ddd           dS # 1 swxY w Y   dS )zwChange the size of the pool during runtime.

        Only *max_size* can be changed; *min_size* must remain 0.
        z&resizing %r to min_size=%s max_size=%sN)_check_sizer@   rA   r!   r>   	_min_size	_max_size)r6   r   r   s      r8   resizezNullConnectionPool.resize   s    
 "--hAA(4di8	
 	
 	
 Z 	& 	&%DN%DN	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	&s   AA#&A#c                    dS )z9No-op, as the pool doesn't have connections in its state.N )r6   s    r8   r   zNullConnectionPool.check   s    r9   c                T   d |_         | j        5  | j        r4| j                                                            |          rnL| j        4|                                 | j        r| j                                         n| xj        dz  c_        d d d            d S # 1 swxY w Y   d S )Nr   )rU   r>   rL   popleftsetrD   r?   rI   rZ   s     r8   _add_to_poolzNullConnectionPool._add_to_pool   s     
 Z 	& 	&- & =((**..t44 	 - & 

 ( &)--//// LLA%LL!	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	&s   BBB!$B!)r   )"r)   r*   r   r   r   r+   r   r,   r   r-   r   r.   r   r/   r   r/   r    r/   r!   r0   r"   r1   r#   r,   r$   r1   r%   r1   r&   r1   r'   r2   r(   r,   )r   )r"   r1   r:   r;   )r"   rE   r:   rF   )rO   r	   r:   rR   )N)r   r,   r   r-   r:   r;   )r:   r;   )rO   r	   r:   r;   )__name__
__module____qualname__r   r   r5   rC   rQ   r[   r`   r   rf   __classcell__)r7   s   @r8   r   r      s        '
 &*T*j%A%A(,# -1)-)-'##+37''
 '
 '
 '
 '
 '
 '
 '
R: : : : ::   (   & & & & &   & & & & & & & &r9   r   )__doc__
__future__r   loggingtypingr   r   psycopgr   
psycopg.pqr   abcr	   r
   r   poolr   r   errorsr   r   _compatr   _acompatr   base_null_poolr   	getLoggerr@   r   rb   r9   r8   <module>rx      sD    # " " " " "                ( ( ( ( ( ( 2 2 2 2 2 2 2 2 2 2 / / / / / / / / 0 0 0 0 0 0 0 0 & & & & & &       3 3 3 3 3 3		>	*	*U& U& U& U& U&0.2D U& U& U& U& U&r9   