
    j                    f   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dS )*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.
    TNblockbooltimeoutfloat | Nonereturnr   c                R    |d}t                                          ||          S )Ng     @)r   r   )superget)selfr   r   	__class__s      [/DATA/AppData/hermes/projects/honcho/.venv/lib/python3.11/site-packages/psycopg/_acompat.pyr   z	Queue.get"   s'    ?(Gww{{{888    )TN)r   r   r   r   r   r   )__name__
__module____qualname____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 )AQueueN)r   r   r    r   r   r!   r!   )   s        Dr   r!   r"   f(Callable[..., Coroutine[Any, Any, None]]argstuple[Any, ...]name
str | Noner   asyncio.Task[None]c                4    t          j         | | |          S )z,
    Equivalent to asyncio.create_task.
    )r'   )asynciocreate_task)r#   r%   r'   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)targetr%   r'   daemon)	threadingThreadstart)r#   r%   r'   ts       r   spawnr7   8   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()
    Nr8   )r+   gatherwait_forshieldTimeoutError)r   r9   waits      r   agatherrC   E   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 )r=   N)is_alivejoin)r   r9   r6   s      r   r>   r>   U   sA       zz|| 		w r   )r"   N)r#   r$   r%   r&   r'   r(   r   r)   )r#   r.   r%   r&   r'   r(   r   r/   )r9   r:   r   r   r   r;   )r9   r/   r   r   r   r;   )r   
__future__r   queuer+   r3   typingr   r   collections.abcr   r   _compatr	   r4   r
   __annotations__Taskr   LockALockr   r   r!   r-   r7   rC   r>   r"   r   r   <module>rP      s     # " " " " "       ! ! ! ! ! ! ! ! / / / / / / / /      $ $ $ $ $\$' ' ' ' '~GCLL	9 	9 	9 	9 	9EKN 	9 	9 	9	 	 	 	 	W]1 	 	 	 4 4 4 4 4 
 
 
 
 
 FJ        >B        r   