
    Owg{
                     ~    d dl Zd dlZd dlmZ d dlmZ d dlmZm	Z	  G d de      Z
 G d de
      Z G d	 d
e
      Zy)    N)abstractmethod)BrokenProcessPool)BaseExecutorrun_jobc                   6     e Zd Ze fd       Zd ZddZ xZS )BasePoolExecutorc                 0    t         |           || _        y N)super__init___pool)selfpool	__class__s     Q/var/www/horilla/myenv/lib/python3.12/site-packages/apscheduler/executors/pool.pyr   zBasePoolExecutor.__init__
   s    
    c                       fd} j                   j                  t        j                  | j                  j
                        }|j                  |       y )Nc                 .   t        | d      r| j                         n*| j                         t        | j                         dd       f\  }}|rj	                  j
                  ||       y j                  j
                  | j                                y )Nexception_info__traceback__)hasattrr   	exceptiongetattr_run_job_errorid_run_job_successresult)fexctbjobr   s      r   callbackz1BasePoolExecutor._do_submit_job.<locals>.callback   sy     1./   "kkmWQ[[]OT%RS C
 ##CFFC4%%cffahhj9r   )r   submitr   _jobstore_alias_loggernameadd_done_callback)r   r!   	run_timesr"   r   s   ``   r   _do_submit_jobzBasePoolExecutor._do_submit_job   sI    		: JJS#--y$,,:K:K
 	
H%r   c                 :    | j                   j                  |       y r
   )r   shutdown)r   waits     r   r+   zBasePoolExecutor.shutdown    s    

D!r   )T)__name__
__module____qualname__r   r   r)   r+   __classcell__r   s   @r   r   r   	   s     &""r   r   c                   $     e Zd ZdZd fd	Z xZS )ThreadPoolExecutora  
    An executor that runs jobs in a concurrent.futures thread pool.

    Plugin alias: ``threadpool``

    :param max_workers: the maximum number of spawned threads.
    :param pool_kwargs: dict of keyword arguments to pass to the underlying
        ThreadPoolExecutor constructor
    c                     |xs i }t        j                  j                  t        |      fi |}t        |   |       y r
   )
concurrentfuturesr3   intr   r   r   max_workerspool_kwargsr   r   s       r   r   zThreadPoolExecutor.__init__/   s:    !'R!!44S5EUUr   
   N)r-   r.   r/   __doc__r   r0   r1   s   @r   r3   r3   $   s     r   r3   c                   .     e Zd ZdZd fd	Z fdZ xZS )ProcessPoolExecutora#  
    An executor that runs jobs in a concurrent.futures process pool.

    Plugin alias: ``processpool``

    :param max_workers: the maximum number of spawned processes.
    :param pool_kwargs: dict of keyword arguments to pass to the underlying
        ProcessPoolExecutor constructor
    c                     |xs i | _         | j                   j                  dt        j                  d             t	        j
                  j                  t        |      fi | j                   }t        | %  |       y )N
mp_contextspawn)
r:   
setdefaultmultiprocessingget_contextr5   r6   r?   r7   r   r   r8   s       r   r   zProcessPoolExecutor.__init__@   sl    &,"##L/2M2Mg2VW!!55
 $ 0 0
 	r   c                    	 t         |   ||       y # t        $ rn | j                  j	                  d        | j
                  j                  | j
                  j                  fi | j                  | _        t         |   ||       Y y w xY w)Nz<Process pool is broken; replacing pool with a fresh instance)	r   r)   r   r%   warningr   r   _max_workersr:   )r   r!   r(   r   s      r   r)   z"ProcessPoolExecutor._do_submit_jobH   s    		3G"3	2  	3LL  N .--

''+/+;+;DJ G"3	2	3s    A4B
Br;   )r-   r.   r/   r=   r   r)   r0   r1   s   @r   r?   r?   5   s    
3 
3r   r?   )concurrent.futuresr5   rD   abcr   concurrent.futures.processr   apscheduler.executors.baser   r   r   r3   r?    r   r   <module>rN      s:       8 <"| "6) "3* 3r   