
    i|
                       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m	Z	m
Z
 ddlmZmZ ej                  Zded<   d	Zded
<    ed      Zer#ej&                  Zded<   ej&                  Zded<   n9 G d de      Z G d dej&                  e      Z G d dej&                  e      Z G d dee         Z G d de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)TYPE_CHECKINGAnyCallable	Coroutine   )	TypeAliasTypeVarr	   Workerasyncio.Task[None]AWorkerT_GQueue_AGQueuec                      e Zd Zd Zy)FakeGenericMetac                    | S )N )selfitems     p/var/www/html/hwPaymentPortal-be-dev/hw-payment-portal-api/venv/lib/python3.12/site-packages/psycopg/_acompat.py__getitem__zFakeGenericMeta.__getitem__!   s    K    N)__name__
__module____qualname__r   r   r   r   r   r       s    	r   r   c                      e Zd Zy)r   Nr   r   r   r   r   r   r   r   $       r   )	metaclassc                      e Zd Zy)r   Nr   r   r   r   r   r   '   r   r   c                  &     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)r   r%   r&   	__class__s      r   r(   z	Queue.get0   s     ?(Gw{{88r   )TN)r%   boolr&   float | Nonereturnr   )r   r   r   __doc__r(   __classcell__)r)   s   @r   r#   r#   +   s    9 9r   r#   c                      e Zd Zy)AQueueNr   r   r   r   r0   r0   7   s    r   r0   c                6    t        j                   | | |      S )z,
    Equivalent to asyncio.create_task.
    )name)asynciocreate_task)fargsr2   s      r   aspawnr7   ;   s     q$xd33r   c                X    t        j                  | ||d      }|j                          |S )z=
    Equivalent to creating and running a daemon thread.
    T)targetr6   r2   daemon)	threadingThreadstart)r5   r6   r2   ts       r   spawnr?   F   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()
    Nr@   )r3   gatherwait_forshieldTimeoutError)r&   taskswaits      r   agatherrI   S   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)rB   N)is_alivejoin)r&   rG   r>   s      r   rC   rC   c   s*      zz|	wr   )r   N)r5   z(Callable[..., Coroutine[Any, Any, None]]r6   tuple[Any, ...]r2   
str | Noner,   r   )r5   zCallable[..., Any]r6   rM   r2   rN   r,   threading.Thread)rG   zasyncio.Task[Any]r&   r+   r,   None)rG   rO   r&   r+   r,   rP   )r-   
__future__r   queuer3   r;   typingr   r   r   r   _compatr	   r
   r<   r   __annotations__r   r   r#   r   r   typer   r0   r7   r?   rI   rC   r   r   r   <module>rW      s.   #    : : '$$	 $) )CL GY$!--Hi'$ %++ 7==O 	9GAJ 	9	Xa[ 	 4/4
4 4 	4 



 
 	
 FJ   >B r   