o
    èÇhh  ã                   @   s.   d dl Z ddlmZ dd„ ZG dd„ dƒZdS )é    Né   )Ú
exceptionsc                    s   t  ˆ ¡‡ fdd„ƒ}|S )z@A decorator to add a sanity check to ConnectionResource methods.c                    s"   |   ˆ j¡ ˆ | g|¢R i |¤ŽS ©N)Ú_check_conn_validityÚ__name__)ÚselfÚargsÚkwargs©Úmeth© úh/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/asyncpg/connresource.pyÚ_check   s   zguarded.<locals>._check)Ú	functoolsÚwraps)r   r   r   r
   r   Úguarded   s   r   c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚConnectionResource)Ú_connectionÚ_con_release_ctrc                 C   s   || _ |j| _d S r   )r   Ú_pool_release_ctrr   )r   Ú
connectionr   r   r   Ú__init__   s   zConnectionResource.__init__c                 C   sL   | j j}|| jkrt d | jj|¡¡‚| j  ¡ r$t d | jj|¡¡‚d S )NzQcannot call {}.{}(): the underlying connection has been released back to the poolz8cannot call {}.{}(): the underlying connection is closed)	r   r   r   r   ÚInterfaceErrorÚformatÚ	__class__r   Ú	is_closed)r   Ú	meth_nameÚcon_release_ctrr   r   r   r       s   
ý
ÿþÿz'ConnectionResource._check_conn_validityN)r   Ú
__module__Ú__qualname__Ú	__slots__r   r   r   r   r   r   r      s    r   )r   Ú r   r   r   r   r   r   r   Ú<module>   s   