o
    ›¨Êh  ã                   @  sš   d Z ddlmZ ddlmZmZmZ ddlmZm	Z	m
Z
 ddlmZmZ dZer<ddlmZ ed	eed
œƒZe
de	f ZG dd„ dƒZG dd„ deƒZdS )zThread execution pool.é    )Úannotations)ÚFutureÚThreadPoolExecutorÚwait)ÚTYPE_CHECKINGÚAnyÚCallableé   )ÚBasePoolÚapply_target)ÚTaskPool)Ú	TypedDictÚPoolInfo©zmax-concurrencyÚthreads.c                   @  s"   e Zd Zddd„Zddd
d„ZdS )ÚApplyResultÚfuturer   ÚreturnÚNonec                 C  s   || _ | j j| _d S ©N)ÚfÚresultÚget)Úselfr   © r   úK/var/www/html/env/lib/python3.10/site-packages/celery/concurrency/thread.pyÚ__init__   s   zApplyResult.__init__NÚtimeoutúfloat | Nonec                 C  s   t | jg|ƒ d S r   )r   r   )r   r   r   r   r   r      s   zApplyResult.wait)r   r   r   r   r   )r   r   r   r   )Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r      s    
r   c                      sd   e Zd ZU dZded< dZdZd‡ fdd„Zd‡ fdd„Z				d d!dd„Z	d"‡ fdd„Z
‡  ZS )#r   zThread Task Pool.ÚintÚlimitTFÚargsr   Úkwargsr   r   c                   s$   t ƒ j|i |¤Ž t| jd�| _d S )N)Úmax_workers)Úsuperr   r   r#   Úexecutor)r   r$   r%   ©Ú	__class__r   r   r   %   s   zTaskPool.__init__c                   s   | j  ¡  tƒ  ¡  d S r   )r(   Úshutdownr'   Úon_stop)r   r)   r   r   r,   )   s   
zTaskPool.on_stopNÚtargetÚTargetFunctionútuple[Any, ...] | Noneúdict[str, Any] | NoneÚcallbackúCallable[..., Any] | NoneÚaccept_callbackÚ_r   c                 K  s   | j  t|||||¡}t|ƒS r   )r(   Úsubmitr   r   )r   r-   r$   r%   r1   r3   r4   r   r   r   r   Úon_apply-   s   	ÿzTaskPool.on_applyr   c                   s(   t ƒ  ¡ }| | jt| jjƒdœ¡ |S )Nr   )r'   Ú	_get_infoÚupdater#   Úlenr(   Ú_threads)r   Úinfor)   r   r   r7   :   s   

þzTaskPool._get_info)r$   r   r%   r   r   r   )r   r   )NNNN)r-   r.   r$   r/   r%   r0   r1   r2   r3   r2   r4   r   r   r   )r   r   )r   r    r!   Ú__doc__Ú__annotations__Úbody_can_be_bufferÚsignal_safer   r,   r6   r7   Ú__classcell__r   r   r)   r   r      s   
 úr   N)r<   Ú
__future__r   Úconcurrent.futuresr   r   r   Útypingr   r   r   Úbaser
   r   Ú__all__r   r"   r   r.   r   r   r   r   r   r   Ú<module>   s    	