AlkantarClanX12

Your IP : 3.133.157.133


Current Path : /opt/alt/python37/lib64/python3.7/concurrent/futures/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/concurrent/futures/__pycache__/thread.cpython-37.pyc

B

� fA�@s�dZdZddlZddlmZddlZddlZddlZddlZddl	Z	e�
�Zdadd�Z
e�e
�Gdd	�d	e�Zd
d�ZGdd
�d
ej�ZGdd�dej�ZdS)zImplements ThreadPoolExecutor.z"Brian Quinlan (brian@sweetapp.com)�N)�_baseFcCsJdatt���}x|D]\}}|�d�qWx|D]\}}|��q2WdS)NT)�	_shutdown�list�_threads_queues�items�put�join)r�t�q�r�>/opt/alt/python37/lib64/python3.7/concurrent/futures/thread.py�_python_exit!sr
c@seZdZdd�Zdd�ZdS)�	_WorkItemcCs||_||_||_||_dS)N)�future�fn�args�kwargs)�selfrrrrrrr�__init__.sz_WorkItem.__init__c
Csf|j��sdSy|j|j|j�}Wn2tk
rT}z|j�|�d}Wdd}~XYnX|j�|�dS)N)rZset_running_or_notify_cancelrrr�
BaseException�
set_exceptionZ
set_result)r�result�excrrr�run4s
z
_WorkItem.runN)�__name__�
__module__�__qualname__rrrrrrr-srcCs�|dk	rPy||�Wn:tk
rNtjjddd�|�}|dk	rJ|��dSXy`xZ|jdd�}|dk	rt|��~qT|�}ts�|dks�|jr�|dk	r�d|_|�d�dS~qTWWn$tk
r�tjjddd�YnXdS)NzException in initializer:T)�exc_info)�blockzException in worker)	rrZLOGGERZcritical�_initializer_failed�getrrr)Zexecutor_referenceZ
work_queue�initializer�initargsZexecutor�	work_itemrrr�_workerBs2

r$c@seZdZdZdS)�BrokenThreadPoolzR
    Raised when a worker thread in a ThreadPoolExecutor failed initializing.
    N)rrr�__doc__rrrrr%fsr%c@sZeZdZe��jZddd�Zdd�Ze	j
jje_dd	�Zd
d�Z
dd
d�Ze	j
jje_dS)�ThreadPoolExecutorN�rcCs�|dkrt��pdd}|dkr(td��|dk	r@t|�s@td��||_t��|_t	�|_
d|_d|_t
��|_|p|d|��|_||_||_dS)	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��rz"max_workers must be greater than 0zinitializer must be a callableFzThreadPoolExecutor-%d)�os�	cpu_count�
ValueError�callable�	TypeError�_max_workers�queueZSimpleQueue�_work_queue�set�_threads�_brokenr�	threadingZLock�_shutdown_lock�_counter�_thread_name_prefix�_initializer�	_initargs)rZmax_workersZthread_name_prefixr!r"rrrrqs 

zThreadPoolExecutor.__init__c	Os�t|�dkr|^}}}n>|s&td��n0d|krB|�d�}|^}}ntdt|�d��|j�Z|jrnt|j��|jr|td��tr�td��t�	�}t
||||�}|j�|�|�
�|SQRXdS)N�zDdescriptor 'submit' of 'ThreadPoolExecutor' object needs an argumentrz6submit expected at least 1 positional argument, got %dr)z*cannot schedule new futures after shutdownz6cannot schedule new futures after interpreter shutdown)�lenr/�popr7r5r%r�RuntimeErrorrZFuturerr2r�_adjust_thread_count)rrrr�f�wrrr�submit�s*



zThreadPoolExecutor.submitcCs�|jfdd�}t|j�}||jkr~d|jp,||f}tj|tt�	||�|j|j
|jfd�}d|_|�
�|j�|�|jt|<dS)NcSs|�d�dS)N)r)�_r
rrr�
weakref_cb�sz;ThreadPoolExecutor._adjust_thread_count.<locals>.weakref_cbz%s_%d)�name�targetrT)r2r=r4r0r9r6ZThreadr$�weakref�refr:r;Zdaemon�start�addr)rrEZnum_threadsZthread_namer	rrrr@�s



z'ThreadPoolExecutor._adjust_thread_countc	Csd|j�Td|_xFy|j��}Wntjk
r6PYnX|dk	r|j�t|j��qWWdQRXdS)NzBA thread initializer failed, the thread pool is not usable anymore)	r7r5r2Z
get_nowaitr1ZEmptyrrr%)rr#rrrr�sz&ThreadPoolExecutor._initializer_failedTc	CsD|j�d|_|j�d�WdQRX|r@x|jD]}|��q0WdS)NT)r7rr2rr4r)r�waitr	rrr�shutdown�szThreadPoolExecutor.shutdown)Nr(Nr)T)rrr�	itertools�count�__next__r8rrCr�Executorr&r@rrMrrrrr'ls


r')r&�
__author__�atexitZconcurrent.futuresrrNr1r6rHr+�WeakKeyDictionaryrrr
�register�objectrr$ZBrokenExecutorr%rQr'rrrr�<module>s 	
$