<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
a
    XC?hC"  ã                   @   sÊ   d Z dZddlmZ ddlZddlZddlZddlZddlZddl	Z	e 
¡ Zdae ¡ Zdd„ Ze e¡ ee	dƒrŠe	jejejejd	 G d
d„ deƒZdd„ ZG dd„ dejƒZG dd„ dejƒZdS )zImplements ThreadPoolExecutor.z"Brian Quinlan (brian@sweetapp.com)é    )Ú_baseNFc                  C   sf   t  daW d   ƒ n1 s0    Y  tt ¡ ƒ} | D ]\}}| d ¡ q8| D ]\}}| ¡  qPd S ©NT)Ú_global_shutdown_lockÚ	_shutdownÚlistÚ_threads_queuesÚitemsÚputÚjoin)r   ÚtÚq© r   ú>/opt/alt/python39/lib64/python3.9/concurrent/futures/thread.pyÚ_python_exit   s    "r   Úregister_at_fork)ZbeforeZafter_in_childZafter_in_parentc                   @   s&   e Zd Zdd„ Zdd„ ZeejƒZdS )Ú	_WorkItemc                 C   s   || _ || _|| _|| _d S ©N)ÚfutureÚfnÚargsÚkwargs)Úselfr   r   r   r   r   r   r   Ú__init__/   s    z_WorkItem.__init__c              
   C   sl   | j  ¡ sd S z| j| ji | j¤Ž}W n4 tyZ } z| j  |¡ d } W Y d }~nd }~0 0 | j  |¡ d S r   )r   Zset_running_or_notify_cancelr   r   r   ÚBaseExceptionÚset_exceptionZ
set_result)r   ÚresultÚexcr   r   r   Úrun5   s    
z_WorkItem.runN)	Ú__name__Ú
__module__Ú__qualname__r   r   ÚclassmethodÚtypesÚGenericAliasÚ__class_getitem__r   r   r   r   r   .   s   r   c                 C   sð   |d urPz||Ž  W n: t yN   tjjddd | ƒ }|d urH| ¡  Y d S 0 zx|jdd}|d urŒ| ¡  ~| ƒ }|d urˆ|j ¡  ~qR| ƒ }t	s¤|d u s¤|j	rÂ|d ur²d|_	| 
d ¡ W d S ~qRW n" t yê   tjjddd Y n0 d S )NzException in initializer:T)Úexc_info)ÚblockzException in worker)r   r   ZLOGGERZcriticalÚ_initializer_failedÚgetr   Ú_idle_semaphoreÚreleaser   r	   )Zexecutor_referenceZ
work_queueÚinitializerÚinitargsZexecutorÚ	work_itemr   r   r   Ú_workerE   s8    

r.   c                   @   s   e Zd ZdZdS )ÚBrokenThreadPoolzR
    Raised when a worker thread in a ThreadPoolExecutor failed initializing.
    N)r   r   r    Ú__doc__r   r   r   r   r/   p   s   r/   c                   @   s`   e Zd Ze ¡ jZddd„Zdd„ Ze	j
jje_dd	„ Zd
d„ Zdddœdd„Ze	j
jje_dS )ÚThreadPoolExecutorNÚ r   c                 C   s¢   |du rt dt ¡ pdd ƒ}|dkr.tdƒ‚|durFt|ƒsFtdƒ‚|| _t ¡ | _	t
 d¡| _tƒ | _d| _d| _t
 ¡ | _|pŽd	|  ¡  | _|| _|| _dS )
a•  Initializes a new ThreadPoolExecutor instance.

        Args:
            max_workers: The maximum number of threads that can be used to
                execute the given calls.
            thread_name_prefix: An optional name prefix to give our threads.
            initializer: A callable used to initialize worker threads.
            initargs: A tuple of arguments to pass to the initializer.
        Né    é   é   r   z"max_workers must be greater than 0zinitializer must be a callableFzThreadPoolExecutor-%d)ÚminÚosÚ	cpu_countÚ
ValueErrorÚcallableÚ	TypeErrorÚ_max_workersÚqueueZSimpleQueueÚ_work_queueÚ	threadingZ	Semaphorer)   ÚsetÚ_threadsÚ_brokenr   ÚLockÚ_shutdown_lockÚ_counterÚ_thread_name_prefixÚ_initializerÚ	_initargs)r   Zmax_workersZthread_name_prefixr+   r,   r   r   r   r   {   s$    


ÿzThreadPoolExecutor.__init__c             	   O   s´   | j š tv | jrt| jƒ‚| jr,tdƒ‚tr8tdƒ‚t ¡ }t||||ƒ}| j	 
|¡ |  ¡  |W  d   ƒ W  d   ƒ S 1 sˆ0    Y  W d   ƒ n1 s¦0    Y  d S )Nz*cannot schedule new futures after shutdownz6cannot schedule new futures after interpreter shutdown)rD   r   rB   r/   r   ÚRuntimeErrorr   ZFuturer   r>   r	   Ú_adjust_thread_count)r   r   r   r   ÚfÚwr   r   r   Úsubmit¡   s    
zThreadPoolExecutor.submitc                 C   sŽ   | j jddrd S | jfdd„}t| jƒ}|| jk rŠd| jp>| |f }tj|t	t
 | |¡| j| j| jfd}| ¡  | j |¡ | jt|< d S )Nr   )Ztimeoutc                 S   s   |  d ¡ d S r   )r	   )Ú_r   r   r   r   Ú
weakref_cb»   s    z;ThreadPoolExecutor._adjust_thread_count.<locals>.weakref_cbz%s_%d)ÚnameÚtargetr   )r)   Úacquirer>   ÚlenrA   r<   rF   r?   ZThreadr.   ÚweakrefÚrefrG   rH   ÚstartÚaddr   )r   rO   Znum_threadsZthread_namer   r   r   r   rJ   ´   s$    


ÿ
ýÿz'ThreadPoolExecutor._adjust_thread_countc              	   C   st   | j Z d| _z| j ¡ }W n tjy4   Y qRY n0 |d ur|j t| jƒ¡ qW d   ƒ n1 sf0    Y  d S )NzBA thread initializer failed, the thread pool is not usable anymore)	rD   rB   r>   Ú
get_nowaitr=   ÚEmptyr   r   r/   )r   r-   r   r   r   r'   Ë   s    
z&ThreadPoolExecutor._initializer_failedTF)Úcancel_futuresc             	   C   s”   | j b d| _|rNz| j ¡ }W n tjy8   Y qNY n0 |d ur|j ¡  q| j d ¡ W d   ƒ n1 sn0    Y  |r| j	D ]}| 
¡  q‚d S r   )rD   r   r>   rX   r=   rY   r   Zcancelr	   rA   r
   )r   ÚwaitrZ   r-   r   r   r   r   ÚshutdownØ   s    
*
zThreadPoolExecutor.shutdown)Nr2   Nr   )T)r   r   r    Ú	itertoolsÚcountÚ__next__rE   r   rM   r   ÚExecutorr0   rJ   r'   r\   r   r   r   r   r1   v   s   
  ÿ
&r1   )r0   Ú
__author__Zconcurrent.futuresr   r]   r=   r?   r"   rT   r7   ÚWeakKeyDictionaryr   r   rC   r   r   Z_register_atexitÚhasattrr   rR   Ú_at_fork_reinitr*   Úobjectr   r.   ZBrokenExecutorr/   r`   r1   r   r   r   r   Ú<module>   s,   

þ+