U
    Æöeg  ã                   @  sÂ   d dl mZ d dlZd dlZd dlZd dl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)é   é
   )Ú	ParamSpecÚPÚTztuple[typing.Callable, dict]ÚNone)ÚargsÚreturnc               
   ‡  sj   t  dt¡ t ¡ 4 I d H š>‰ dddœ‡ fdd„}| D ]\}}ˆ  |tj|f|Ž¡ q6W 5 Q I d H R X d S )NzOrun_until_first_complete is deprecated and will be removed in a future version.z%typing.Callable[[], typing.Coroutine]r   )Úfuncr
   c                 “  s   | ƒ I d H  ˆ j  ¡  d S ©N)Zcancel_scopeÚcancel)r   ©Z
task_group© ú9/tmp/pip-unpacked-wheel-2mv5qoba/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typing.Callable[P, T]zP.argszP.kwargs)r   r	   r   r
   c                 Ï  s*   |rt j| f|Ž} tjj| f|žŽ 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typing.Iterator[T])Úiteratorr
   c                 C  s(   z
t | ƒW S  tk
r"   t‚Y nX d S r   )ÚnextÚStopIterationr   )r!   r   r   r   Ú_next1   s    
r$   ztyping.Iterable[T]ztyping.AsyncIterator[T]c                 C sB   t | ƒ}ztj t|¡I d H V  W q tk
r:   Y q>Y qX qd S r   )Úiterr   r   r   r$   r   )r!   Zas_iteratorr   r   r   Úiterate_in_threadpool;   s
    r&   )Ú
__future__r   r   ÚsysÚtypingr   Zanyio.to_threadr   Úversion_infor   Ztyping_extensionsr   ÚTypeVarr   r   r   Ú	Exceptionr   r$   r&   r   r   r   r   Ú<module>   s   

	
