o
    h	                     @  s   d dl mZ d dlZd dlZd dlZd dlZejrddlmZ ej	dk r+d dl
mZ nd dlmZ edZdddZdddZdddZdS )    )annotationsN   )compat)      )timeout_Tfutcompat.Awaitable[_T]r   float | Nonereturnc              
     s   |dur3|dkr3t | } |  r|  S t| I dH  z|  W S  t jy2 } zt|d}~ww t|4 I dH  | I dH W  d  I dH  S 1 I dH sQw   Y  dS )a  Wait for the single Future or coroutine to complete, with timeout.

    Coroutine will be wrapped in Task.

    Returns result of the Future or coroutine.  When a timeout occurs,
    it cancels the task and raises TimeoutError.  To avoid the task
    cancellation, wrap it in shield().

    If the wait is cancelled, the task is also cancelled.

    If the task supresses the cancellation and returns a value instead,
    that value is returned.

    This function is a coroutine.
    Nr   )asyncioensure_futuredoneresult_cancel_and_waitCancelledErrorTimeoutErrortimeout_ctx)r	   r   exc r   k/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/asyncpg/_asyncio_compat.pywait_for   s   "

0r   asyncio.Future[_T]Nonec              	     sX   t  }| }tt|}| | z|   |I dH  W | | dS | | w )z<Cancel the *fut* future or task and wait until it completes.N)	r   get_running_loopcreate_future	functoolspartial_release_waiteradd_done_callbackcancelremove_done_callback)r	   loopwaitercbr   r   r   r   K   s   
r   r$   asyncio.Future[typing.Any]argsobjectc                 G  s   |   s| d  d S d S )N)r   
set_result)r$   r'   r   r   r   r   \   s   r   )r	   r
   r   r   r   r   )r	   r   r   r   )r$   r&   r'   r(   r   r   )
__future__r   r   r   systypingTYPE_CHECKING r   version_infoasync_timeoutr   r   TypeVarr   r   r   r   r   r   r   r   <module>   s   



2