
    `f;              	           d Z ddlmZ ddlmZ ddlmZ 	 ddlm	Z	 n# e
$ r dZ	Y nw xY wdZd	dddddde	ej        f	d
Z G d dej                  Z G d dej                  ZdS )zGevent execution pool.    )	monotonic)timer   )base)TimeoutN)TaskPool c
           	          |si n|}	  ||          5   |	| |||||fd|fi|
cd d d            S # 1 swxY w Y   d S # |$ r  |d|          cY S w xY w)N	propagateFr	   )targetargskwargscallbackaccept_callbackpidtimeouttimeout_callbackr   apply_targetrests              K/var/www/html/env/lib/python3.11/site-packages/celery/concurrency/gevent.pyapply_timeoutr      s     )RR6F0WW 	> 	><fh /> >+2*>8<> >	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	>  0 0 0w/////0s'   > 1> 5> 5> AAc                   F     e Zd Z fdZd Zd Zd Zed             Z xZ	S )Timerc                     ddl mm}  G fdd          }|| _        || _         t                      j        |i | t                      | _        d S )Nr   )GreenletGreenletExitc                       e Zd Z j        ZdS )!Timer.__init__.<locals>._GreenletN)__name__
__module____qualname__killcancel)r   s   r   	_Greenletr   &   s        ]FFF    r$   )	geventr   r   r$   _GreenletExitsuper__init__set_queue)selfr   r   r   r$   r   	__class__s        @r   r)   zTimer.__init__#   s    11111111	# 	# 	# 	# 	# 	# 	# 	# 	# 	# #)$)&)))eer%   c                    t          |t                      z
  d          }| j                            ||          }| j                            |           |                    | j                   ||_        ||_	        ||_
        d|_        |S )Nr   F)maxr   r$   spawn_laterr+   addlink_entry_exitentryetaprioritycanceled)r,   r5   r6   r4   r   secsgs          r   _enterzTimer._enter.   s{    3$a((N&&tU33	t   

r%   c                     	 |                                  | j                            |           d S # | j                            |           w xY wN)r"   r+   discard)r,   r9   s     r   r3   zTimer._entry_exit9   sL    	#FFHHHK"""""DK""""s	   2 Ac                     | j         }|r<	 |                                                                 n# t          $ r Y nw xY w|:d S d S r<   )r+   popr"   KeyError)r,   queues     r   clearzTimer.clear?   sq     			  """"     	 	 	 	 	s   &2 
??c                     | j         S r<   )r+   r,   s    r   rA   zTimer.queueG   s
    {r%   )
r   r    r!   r)   r:   r3   rB   propertyrA   __classcell__r-   s   @r   r   r   !   s        	 	 	 	 		 	 	# # #     X    r%   r   c                        e Zd ZdZeZdZdZdZdZdZ	 fdZ
d Zd Zddddddej        fdZdd
ZddZed             Z xZS )r   zGEvent Pool.FTNc                     ddl m} ddlm} || _        || _        |                    d          | _         t                      j        |i | d S )Nr   )	spawn_raw)Poolr   )	r&   rJ   gevent.poolrK   spawn_ngetr   r(   r)   )r,   r   r   rJ   rK   r-   s        r   r)   zTaskPool.__init__W   sj    $$$$$$$$$$$$	 zz),,$)&)))))r%   c                 f    |                      | j                  | _        | j        j        | _        d S r<   )rK   limit_poolspawn
_quick_putrD   s    r   on_startzTaskPool.on_start_   s'    YYtz**
**r%   c                 J    | j         | j                                          d S d S r<   )rQ   joinrD   s    r   on_stopzTaskPool.on_stopc   s*    :!JOO "!r%   c	           
      d    || j         n|}|                     |rt          n||||||||          S )N)r   r   )r   rS   r   )
r,   r   r   r   r   r   r   r   r   _s
             r   on_applyzTaskPool.on_applyg   sM     #*/$,,wI}}\%tVX'.0@  B B 	Br%   r   c                 d    | j         j        xj        |z  c_        | j         xj        |z  c_        d S r<   rQ   
_semaphorecountersizer,   ns     r   growzTaskPool.growp   1    
%%*%%
1r%   c                 d    | j         j        xj        |z  c_        | j         xj        |z  c_        d S r<   r\   r`   s     r   shrinkzTaskPool.shrinkt   rc   r%   c                 *    t          | j                  S r<   )lenrQ   rD   s    r   num_processeszTaskPool.num_processesx   s    4:r%   )r   )r   r    r!   __doc__r   signal_safeis_greentask_join_will_blockrQ   rS   r)   rT   rW   r   r   rZ   rb   re   rE   rh   rF   rG   s   @r   r   r   L   s        EKH EJ* * * * *+ + +   %)!%t"&T5FB B B B         X    r%   r   )ri   timer   kombu.asynchronousr   _timer r   r&   r   ImportError__all__r   r   r   BasePoolr   r	   r%   r   <module>rt      s           . . . . . .         GGG   "$"&D$#'#00 0 0 0( ( ( ( (FL ( ( (V. . . . .t} . . . . .s    ''