
    R
h|
                       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<   n8 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dS )0z
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dS )FakeGenericMetac                    | S )N )selfitems     [/var/www/html/01_SiteInternet/03_Maps/venv/lib/python3.11/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dS )r   Nr   r   r   r   r   r   r   r   $           r   )	metaclassc                      e Zd ZdS )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.
    TNblockbooltimeoutfloat | Nonereturnr   c                R    |d}t                                          ||          S )Ng     @)r$   r&   )superget)r   r$   r&   	__class__s      r   r+   z	Queue.get0   s'    ?(Gww{{{888r   )TN)r$   r%   r&   r'   r(   r   )r   r   r   __doc__r+   __classcell__)r,   s   @r   r#   r#   +   sL         9 9 9 9 9 9 9 9 9 9 9r   r#   c                      e Zd ZdS )AQueueNr   r   r   r   r0   r0   7   s        Dr   r0   r   f(Callable[..., Coroutine[Any, Any, None]]argstuple[Any, ...]name
str | Noner(   c                4    t          j         | | |          S )z,
    Equivalent to asyncio.create_task.
    )r5   )asynciocreate_task)r1   r3   r5   s      r   aspawnr:   ;   s      qq$xd3333r   Callable[..., Any]threading.Threadc                ^    t          j        | ||d          }|                                 |S )z=
    Equivalent to creating and running a daemon thread.
    T)targetr3   r5   daemon)	threadingThreadstart)r1   r3   r5   ts       r   spawnrD   F   s/     	4EEEAGGIIIHr   r&   tasksasyncio.Task[Any]r&   r'   Nonec                   K   t          j        | }	 | /t          j        t          j        |          |            d{V  n| d{V  dS # t           j        $ r Y dS w xY w)7
    Equivalent to asyncio.gather or Thread.join()
    NrE   )r8   gatherwait_forshieldTimeoutError)r&   rF   waits      r   agatherrP   S   s       >5!D"7>$#7#7IIIIIIIIIIIJJJJJJJ 	    s   9A A A c                d    |D ],}|                                 s|                    |            -dS )rJ   N)is_alivejoin)r&   rF   rC   s      r   rK   rK   c   sA       zz|| 		w r   )r   N)r1   r2   r3   r4   r5   r6   r(   r   )r1   r;   r3   r4   r5   r6   r(   r<   )rF   rG   r&   r'   r(   rH   )rF   r<   r&   r'   r(   rH   )r-   
__future__r   queuer8   r@   typingr   r   r   r   _compatr	   r
   rA   r   __annotations__r   r   r#   r   r   typer   r0   r:   rD   rP   rK   r   r   r   <module>rZ      sh     # " " " " "       : : : : : : : : : : : : ' ' ' ' ' ' ' '$ $ $ $ $) ) ) ) )GCLL  G$$$$!-H'''''    $       %+        7=O    	9 	9 	9 	9 	9GAJ 	9 	9 	9	 	 	 	 	Xa[ 	 	 	 4 4 4 4 4 
 
 
 
 
 FJ        >B        r   