o
    ³tÃh´	  ã                   @   s€   d dl mZ d dlZd dlmZmZ zd dlmZ W n e	y%   dZY nw G dd„ deƒZ
G dd„ de
ƒZG d	d
„ d
e
ƒZdS )é    )ÚabstractmethodN)ÚBaseExecutorÚrun_job)ÚBrokenProcessPoolc                       s2   e Zd Ze‡ fdd„ƒZdd„ Zddd„Z‡  ZS )	ÚBasePoolExecutorc                    s   t t| ƒ ¡  || _d S ©N)Úsuperr   Ú__init__Ú_pool)ÚselfÚpool©Ú	__class__© úP/var/www/html/bot/env/lib/python3.10/site-packages/apscheduler/executors/pool.pyr	      s   
zBasePoolExecutor.__init__c              
      s†   ‡ ‡fdd„}zˆj  tˆ ˆ j|ˆjj¡}W n% ty;   ˆj d¡ ˆj  ˆj j	¡ˆ_ ˆj  tˆ ˆ j|ˆjj¡}Y nw | 
|¡ d S )Nc                    s\   t | dƒr	|  ¡ n|  ¡ t|  ¡ dd ƒf\}}|r#ˆ ˆ j||¡ d S ˆ ˆ j|  ¡ ¡ d S )NÚexception_infoÚ__traceback__)Úhasattrr   Ú	exceptionÚgetattrÚ_run_job_errorÚidÚ_run_job_successÚresult)ÚfÚexcÚtb©Újobr   r   r   Úcallback   s   ÿz1BasePoolExecutor._do_submit_job.<locals>.callbackz<Process pool is broken; replacing pool with a fresh instance)r
   Úsubmitr   Ú_jobstore_aliasÚ_loggerÚnamer   Úwarningr   Ú_max_workersÚadd_done_callback)r   r   Ú	run_timesr   r   r   r   r   Ú_do_submit_job   s   ýzBasePoolExecutor._do_submit_jobTc                 C   s   | j  |¡ d S r   )r
   Úshutdown)r   Úwaitr   r   r   r)   $   s   zBasePoolExecutor.shutdown)T)Ú__name__Ú
__module__Ú__qualname__r   r	   r(   r)   Ú__classcell__r   r   r   r   r      s
    r   c                       ó"   e Zd ZdZd‡ fdd„	Z‡  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
    é
   Nc                    ó4   |pi }t jjt|ƒfi |¤Ž}tt| ƒ |¡ d S r   )Ú
concurrentÚfuturesr0   Úintr   r	   ©r   Úmax_workersÚpool_kwargsr   r   r   r   r	   3   ó   zThreadPoolExecutor.__init__©r1   N©r+   r,   r-   Ú__doc__r	   r.   r   r   r   r   r0   (   ó    
r0   c                       r/   )Ú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
    r1   Nc                    r2   r   )r3   r4   r>   r5   r   r	   r6   r   r   r   r	   D   r9   zProcessPoolExecutor.__init__r:   r;   r   r   r   r   r>   9   r=   r>   )Úabcr   Úconcurrent.futuresr3   Úapscheduler.executors.baser   r   Úconcurrent.futures.processr   ÚImportErrorr   r0   r>   r   r   r   r   Ú<module>   s    ÿ