o
    li                     @  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r6d dl
mZ nd dlmZ edZedZd ddZd!ddZG dd deZd"ddZd#ddZdS )$    )annotationsN)AsyncIterator	CoroutineIterableIterator)CallableTypeVar)   
   )	ParamSpecPTargstuple[Callable, dict]returnNonec               	     s   t dt t 4 I d H ' d fdd}| D ]\}} |tj|fi | qW d   I d H  d S 1 I d H s<w   Y  d S )	NzOrun_until_first_complete is deprecated and will be removed in a future version.funcCallable[[], Coroutine]r   r   c                   s   |  I d H   j   d S N)Zcancel_scopecancel)r   Z
task_group \/home/app/PaddleOCR-VL/.venv_paddleocr/lib/python3.10/site-packages/starlette/concurrency.pyrun   s   z%run_until_first_complete.<locals>.run)r   r   r   r   )warningswarnDeprecationWarninganyioZcreate_task_groupZ
start_soon	functoolspartial)r   r   r   kwargsr   r   r   run_until_first_complete   s   .r!   r   Callable[P, T]P.argsr    P.kwargsc                   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(   iteratorIterator[T]c                 C  s   zt | W S  ty   tw r   )nextStopIterationr(   )r,   r   r   r   _next-   s
   
r0   Iterable[T]AsyncIterator[T]c                 C s>   t | }	 ztjt|I d H V  W n
 ty   Y d S w qr   )iterr   r%   r&   r0   r(   )r,   Zas_iteratorr   r   r   iterate_in_threadpool7   s   r4   )r   r   r   r   )r   r"   r   r#   r    r$   r   r   )r,   r-   r   r   )r,   r1   r   r2   )
__future__r   r   sysr   collections.abcr   r   r   r   typingr   r   Zanyio.to_threadr   version_infor   Ztyping_extensionsr   r   r!   r'   	Exceptionr(   r0   r4   r   r   r   r   <module>   s"    




