o
    ³tÃhô  ã                   @   sˆ   d dl mZ d dlZd dlmZ d dlmZ d dlmZm	Z	 zd dl
mZ d dlmZ W n ey9   dd	„ ZY nw G d
d„ deƒZdS )é    )Úabsolute_importN)ÚThreadPoolExecutor)Úconvert_yielded)ÚBaseExecutorÚrun_job)Úrun_coroutine_job)Úiscoroutinefunction_partialc                 C   s   dS )NF© )Úfuncr	   r	   úS/var/www/html/bot/env/lib/python3.10/site-packages/apscheduler/executors/tornado.pyr      s   r   c                       s6   e Zd ZdZd	‡ fdd„	Z‡ fdd„Zdd„ Z‡  ZS )
ÚTornadoExecutorak  
    Runs jobs either in a thread pool or directly on the I/O loop.

    If the job function is a native coroutine function, it is scheduled to be run directly in the
    I/O loop as soon as possible. All other functions are run in a thread pool.

    Plugin alias: ``tornado``

    :param int max_workers: maximum number of worker threads in the thread pool
    é
   c                    s   t t| ƒ ¡  t|ƒ| _d S ©N)Úsuperr   Ú__init__r   Úexecutor)ÚselfÚmax_workers©Ú	__class__r	   r   r      s   zTornadoExecutor.__init__c                    s   t t| ƒ ||¡ |j| _d S r   )r   r   ÚstartÚ_ioloop)r   Ú	schedulerÚaliasr   r	   r   r   "   s   zTornadoExecutor.startc                    s^   ‡ ‡fdd„}t ˆ jƒrtˆ ˆ j|ˆjjƒ}nˆj tˆ ˆ j|ˆjj¡}t	|ƒ}| 
|¡ d S )Nc                    sT   z|   ¡ }W n ty    ˆjˆ jgt ¡ dd … ¢R Ž  Y d S w ˆ ˆ j|¡ d S )Né   )ÚresultÚBaseExceptionÚ_run_job_errorÚidÚsysÚexc_infoÚ_run_job_success)ÚfÚevents©Újobr   r	   r   Úcallback'   s   &ÿz0TornadoExecutor._do_submit_job.<locals>.callback)r   r
   r   Ú_jobstore_aliasÚ_loggerÚnamer   Úsubmitr   r   Úadd_done_callback)r   r%   Ú	run_timesr&   r"   r	   r$   r   Ú_do_submit_job&   s   
ÿzTornadoExecutor._do_submit_job)r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r-   Ú__classcell__r	   r	   r   r   r      s
    r   )Ú
__future__r   r   Úconcurrent.futuresr   Útornado.genr   Úapscheduler.executors.baser   r   Úapscheduler.executors.base_py3r   Úapscheduler.utilr   ÚImportErrorr   r	   r	   r	   r   Ú<module>   s    ÿ