a
    c	gg                     @  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               	     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  q1 I d H sz0    Y  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 X/var/www/html/llm_bihealth/app/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typing.Callable[P, T]zP.argszP.kwargs)r   r	   r   r
   c                   s0   |rt j| fi |} tjj| g|R  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y    tY n0 d S r   )nextStopIterationr   )r!   r   r   r   _next1   s    
r$   ztyping.Iterable[T]ztyping.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_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   

	
