a
    ¦¿hú  ã                   @  sà   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 d dlZejdkrld dl
mZ nd dlmZ edƒZedƒZd	d
dœdd„Zdddddœdd„ZG dd„ deƒZdddœdd„Zdddœdd„ZdS )é    )ÚannotationsN)ÚAsyncIteratorÚ	CoroutineÚIterableÚIterator)ÚCallableÚTypeVar)é   é
   )Ú	ParamSpecÚPÚTztuple[Callable, dict]ÚNone)ÚargsÚreturnc               	   ‡  sˆ   t  dt¡ t ¡ 4 I d H šR‰ dddœ‡ fdd„}| D ]"\}}ˆ  |tj|fi |¤Ž¡ q6W d   ƒI d H  q„1 I d H sz0    Y  d S )NzOrun_until_first_complete is deprecated and will be removed in a future version.zCallable[[], Coroutine]r   )Úfuncr   c                 “  s   | ƒ I d H  ˆ j  ¡  d S ©N)Zcancel_scopeÚcancel)r   ©Z
task_group© úQ/var/www/html/assistant/venv/lib/python3.9/site-packages/starlette/concurrency.pyÚrun   s    z%run_until_first_complete.<locals>.run)ÚwarningsÚwarnÚDeprecationWarningÚanyioZcreate_task_groupZ
start_soonÚ	functoolsÚpartial)r   r   r   Úkwargsr   r   r   Úrun_until_first_complete   s    þr   zCallable[P, T]zP.argszP.kwargs)r   r   r   r   c                 Ï  s*   t j| g|¢R i |¤Ž} tj | ¡I d H S r   )r   r   r   Ú	to_threadÚrun_sync)r   r   r   r   r   r   Úrun_in_threadpool$   s    r"   c                   @  s   e Zd ZdS )Ú_StopIterationN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r#   )   s   r#   zIterator[T])Úiteratorr   c                 C  s&   z
t | ƒW S  ty    t‚Y n0 d S r   )ÚnextÚStopIterationr#   )r'   r   r   r   Ú_next-   s    
r*   zIterable[T]zAsyncIterator[T]c                 C s@   t | ƒ}ztj t|¡I d H V  W q ty8   Y q<Y q0 qd S r   )Úiterr   r    r!   r*   r#   )r'   Zas_iteratorr   r   r   Úiterate_in_threadpool7   s
    r,   )Ú
__future__r   r   Úsysr   Úcollections.abcr   r   r   r   Útypingr   r   Zanyio.to_threadr   Úversion_infor   Ztyping_extensionsr   r   r   r"   Ú	Exceptionr#   r*   r,   r   r   r   r   Ú<module>   s    

