
    2i                       U d Z ddlmZ ddlZddlZddlZddlmZmZ ddl	m
Z
mZ ddlmZ ej                  Zded	<   ej"                  d   Zded
<   ej&                  Zej&                  Z ed      Z G d dej,                  e         Z G d dej,                  e         Z	 	 d	 	 	 	 	 	 	 ddZ	 	 d	 	 	 	 	 	 	 ddZddddZddddZy)z
Utilities to ease the differences between async and sync code.

These object offer a similar interface between sync and async versions; the
script async_to_sync.py will replace the async names with the sync names
when generating the sync version.
    )annotationsN)Any	TypeAlias)Callable	Coroutine   )TypeVarr   WorkerAWorkerTc                  &     e Zd ZdZdd fdZ xZS )Queuez>
    A Queue subclass with an interruptible get() method.
    c                .    |d}t         |   ||      S )Ng     @)blocktimeout)superget)selfr   r   	__class__s      O/var/www/html/secretsanta/venv/lib/python3.12/site-packages/psycopg/_acompat.pyr   z	Queue.get"   s     ?(Gw{{88    )TN)r   boolr   float | Nonereturnr   )__name__
__module____qualname____doc__r   __classcell__)r   s   @r   r   r      s    9 9r   r   c                      e Zd Zy)AQueueN)r   r   r    r   r   r!   r!   )   s    r   r!   c                6    t        j                   | | |      S )z,
    Equivalent to asyncio.create_task.
    )name)asynciocreate_task)fargsr$   s      r   aspawnr)   -   s     q$xd33r   c                X    t        j                  | ||d      }|j                          |S )z=
    Equivalent to creating and running a daemon thread.
    T)targetr(   r$   daemon)	threadingThreadstart)r'   r(   r$   ts       r   spawnr1   8   s(     	4EAGGIHr   r   c                   K   t        j                  | }	 | 3t        j                  t        j                  |      |        d{    y| d{    	 y7 7 # t         j                  $ r Y yw xY ww)7
    Equivalent to asyncio.gather or Thread.join()
    Nr2   )r%   gatherwait_forshieldTimeoutError)r   taskswaits      r   agatherr;   E   st      >>5!D""7>>$#7III 		 JJ 	 J sX   A4/A AA 
A4A AA A4A A A1.A40A11A4c                V    |D ]$  }|j                         s|j                  |        & y)r4   N)is_alivejoin)r   r9   r0   s      r   r5   r5   U   s*      zz|	wr   )r"   N)r'   z(Callable[..., Coroutine[Any, Any, None]]r(   tuple[Any, ...]r$   
str | Noner   zasyncio.Task[None])r'   zCallable[..., Any]r(   r?   r$   r@   r   threading.Thread)r9   zasyncio.Task[Any]r   r   r   None)r9   rA   r   r   r   rB   )r   
__future__r   queuer%   r-   typingr   r   collections.abcr   r   _compatr	   r.   r
   __annotations__Taskr   LockALockr   r   r!   r)   r1   r;   r5   r"   r   r   <module>rL      s   #    ! / $$	 $\\$' '~~CL	9EKKN 	9	W]]1 	 4/4
4 4 	4 



 
 	
 FJ   >B r   