AlkantarClanX12

Your IP : 3.144.249.63


Current Path : /opt/alt/python39/lib64/python3.9/concurrent/futures/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/concurrent/futures/__pycache__/process.cpython-39.opt-2.pyc

a

R�f�z�@s~dZddlZddlmZddlZddlZddlZddlm	Z	ddl
Z
ddlZddlm
Z
ddlZddlZddlZe��ZdaGdd�d�Zd	d
�Ze
�e�dZdZGd
d�de�ZGdd�d�Zdd�ZGdd�de�ZGdd�de�ZGdd�de�Z Gdd�de	�Z!dd�Z"dd�Z#d-dd �Z$d!d"�Z%Gd#d$�d$e
j&�Z'da(da)d%d&�Z*d'd(�Z+Gd)d*�d*ej,�Z-Gd+d,�d,ej.�Z/dS).z"Brian Quinlan (brian@sweetapp.com)�N)�_base)�Queue)�partialFc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�
_ThreadWakeupcCsd|_tjdd�\|_|_dS)NF)Zduplex)�_closed�mpZPipe�_reader�_writer��self�r�?/opt/alt/python39/lib64/python3.9/concurrent/futures/process.py�__init__Csz_ThreadWakeup.__init__cCs$|js d|_|j��|j��dS�NT)rr	�closerr
rrr
rGs
z_ThreadWakeup.closecCs|js|j�d�dS)N�)rr	Z
send_bytesr
rrr
�wakeupMsz_ThreadWakeup.wakeupcCs |js|j��r|j��qdS�N)rrZpollZ
recv_bytesr
rrr
�clearQs
z_ThreadWakeup.clearN)�__name__�
__module__�__qualname__rrrrrrrr
rBsrcCs@datt���}|D]\}}|��q|D]\}}|��q*dSr)�_global_shutdown�list�_threads_wakeups�itemsr�join)r�_�
thread_wakeup�trrr
�_python_exitWs
r ��=c@seZdZdd�Zdd�ZdS)�_RemoteTracebackcCs
||_dSr��tb)rr%rrr
rwsz_RemoteTraceback.__init__cCs|jSrr$r
rrr
�__str__ysz_RemoteTraceback.__str__N)rrrrr&rrrr
r#vsr#c@seZdZdd�Zdd�ZdS)�_ExceptionWithTracebackcCs8t�t|�||�}d�|�}||_d|j_d||_dS)N�z

"""
%s""")�	traceback�format_exception�typer�exc�
__traceback__r%)rr,r%rrr
r}s

z _ExceptionWithTraceback.__init__cCst|j|jffSr)�_rebuild_excr,r%r
rrr
�
__reduce__�sz"_ExceptionWithTraceback.__reduce__N)rrrrr/rrrr
r'|sr'cCst|�|_|Sr)r#�	__cause__)r,r%rrr
r.�s
r.c@seZdZdd�ZdS)�	_WorkItemcCs||_||_||_||_dSr)�future�fn�args�kwargs)rr2r3r4r5rrr
r�sz_WorkItem.__init__N�rrrrrrrr
r1�sr1c@seZdZddd�ZdS)�_ResultItemNcCs||_||_||_dSr)�work_id�	exception�result)rr8r9r:rrr
r�sz_ResultItem.__init__)NNr6rrrr
r7�sr7c@seZdZdd�ZdS)�	_CallItemcCs||_||_||_||_dSr)r8r3r4r5)rr8r3r4r5rrr
r�sz_CallItem.__init__Nr6rrrr
r;�sr;cs*eZdZd�fdd�	Z�fdd�Z�ZS)�
_SafeQueuercs&||_||_||_t�j||d�dS)N)�ctx)�pending_work_items�
shutdown_lockr�superr)r�max_sizer=r>r?r��	__class__rr
r�sz_SafeQueue.__init__cs�t|t�r�t�t|�||j�}td�d�|���|_	|j
�|jd�}|j
�|j��Wd�n1sj0Y|dur�|j�|�nt��||�dS)Nz

"""
{}"""r()�
isinstancer;r)r*r+r-r#�formatrr0r>�popr8r?rrr2�
set_exceptionr@�_on_queue_feeder_error)r�e�objr%�	work_itemrBrr
rH�s
(z!_SafeQueue._on_queue_feeder_error)r)rrrrrH�
__classcell__rrrBr
r<�sr<cgs,t|�}tt�||��}|s dS|VqdSr)�zip�tuple�	itertools�islice)�	chunksize�	iterables�it�chunkrrr
�_get_chunks�s
rUcs�fdd�|D�S)Ncsg|]}�|��qSrr)�.0r4�r3rr
�
<listcomp>�rz"_process_chunk.<locals>.<listcomp>r)r3rTrrWr
�_process_chunk�s	rYc
Cs`z|�t|||d��WnBtyZ}z*t||j�}|�t||d��WYd}~n
d}~00dS)N)r:r9�r9)�putr7�
BaseExceptionr'r-)�result_queuer8r:r9rIr,rrr
�_sendback_result�s
�r^c
Cs�|dur:z||�Wn$ty8tjjddd�YdS0|jdd�}|dur`|�t���dSz|j|j	i|j
��}Wn@ty�}z(t||j�}t
||j|d�WYd}~nd}~00t
||j|d�~~q:dS)NzException in initializer:T)�exc_info��blockrZ)r:)r\rZLOGGERZcritical�getr[�os�getpidr3r4r5r'r-r^r8)�
call_queuer]�initializer�initargsZ	call_item�rrIr,rrr
�_process_worker�s$
&ricsleZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
�ZS)�_ExecutorManagerThreadcsf|j|_|j|_|j|jfdd�}t�||�|_|j|_|j	|_
|j|_|j
|_|j|_t���dS)NcSs<tj�d�|�|��Wd�n1s.0YdS)Nz?Executor collected: triggering callback for QueueManager wakeup)r�util�debugr)rrr?rrr
�
weakref_cbsz3_ExecutorManagerThread.__init__.<locals>.weakref_cb)�_executor_manager_thread_wakeupr�_shutdown_lockr?�weakref�ref�executor_reference�
_processes�	processes�_call_queuere�
_result_queuer]�	_work_ids�work_ids_queue�_pending_work_itemsr>r@r)r�executorrmrBrr
rs	�
z_ExecutorManagerThread.__init__cCs�|��|��\}}}|r(|�|�dS|durX|�|�~|��}|durV|j��~|��r|��|j	s|�
�dSqdSr)�add_call_item_to_queue�wait_result_broken_or_wakeup�terminate_broken�process_result_itemrr�_idle_worker_semaphore�release�is_shutting_down�flag_executor_shutting_downr>�join_executor_internals)r�result_item�	is_broken�causerzrrr
�run:s"


z_ExecutorManagerThread.runcCs~|j��rdSz|jjdd�}Wntjy6YdS0|j|}|j��rn|jj	t
||j|j|j
�dd�q|j|=qqdS)NFr`T)reZfullrxrb�queue�Emptyr>r2Zset_running_or_notify_cancelr[r;r3r4r5)rr8rKrrr
r{Zs"



��z-_ExecutorManagerThread.add_call_item_to_queuec

Cs�|jj}|jj}||g}dd�t|j���D�}tj�||�}d}d}d}||vr�z|�	�}d}Wq�t
y�}	z t�t
|	�|	|	j�}WYd}	~	q�d}	~	00n||vr�d}|j�|j��Wd�n1s�0Y|||fS)NcSsg|]
}|j�qSr)�sentinel�rV�prrr
rX{rzG_ExecutorManagerThread.wait_result_broken_or_wakeup.<locals>.<listcomp>TF)r]rrrrt�valuesrZ
connection�waitZrecvr\r)r*r+r-r?r)
rZ
result_readerZ
wakeup_readerZreadersZworker_sentinelsZreadyr�r�r�rIrrr
r|qs&,(z3_ExecutorManagerThread.wait_result_broken_or_wakeupcCsrt|t�r2|j�|�}|��|jsn|��dSn<|j�|jd�}|durn|jr`|j	�
|j�n|j	�|j�dSr)
rD�intrtrFrr�r>r8r9r2rGZ
set_resultr:)rr�r�rKrrr
r~�s
z*_ExecutorManagerThread.process_result_itemcCs|��}tp|dup|jSr)rrr�_shutdown_thread)rrzrrr
r��s�z'_ExecutorManagerThread.is_shutting_downcCs�|��}|dur d|_d|_d}td�}|durHtdd�|��d��|_|j��D]\}}|j	�
|�~qR|j��|j�
�D]}|��q~|��dS)NzKA child process terminated abruptly, the process pool is not usable anymoreTz^A process in the process pool was terminated abruptly while the future was running or pending.z
'''
r(z''')rr�_brokenr��BrokenProcessPoolr#rr0r>rr2rGrrtr�Z	terminater�)rr�rzZbper8rKr�rrr
r}�s"�

z'_ExecutorManagerThread.terminate_brokencCs�|��}|dur|d|_|jr|i}|j��D]\}}|j��s*|||<q*||_z|j��WqLt	j
yrYqvYqL0qLd|_dS)NTF)rrr��_cancel_pending_futuresr>rr2ZcancelrxZ
get_nowaitr�r�)rrzZnew_pending_work_itemsr8rKrrr
r��s

z2_ExecutorManagerThread.flag_executor_shutting_downc	Csl|��}d}||krh|��dkrht||�D]8}z|j�d�|d7}Wq,tjybYqYq,0q,qdS)Nrr!)�get_n_children_alive�rangereZ
put_nowaitr�ZFull)rZn_children_to_stopZn_sentinels_sent�irrr
�shutdown_workers�s
�z'_ExecutorManagerThread.shutdown_workerscCsh|��|j��|j��|j�|j��Wd�n1sB0Y|j��D]}|��qVdSr)	r�rerZjoin_threadr?rrtr�r�rr�rrr
r��s

(z._ExecutorManagerThread.join_executor_internalscCstdd�|j��D��S)Ncss|]}|��VqdSr)Zis_aliver�rrr
�	<genexpr>
rz>_ExecutorManagerThread.get_n_children_alive.<locals>.<genexpr>)�sumrtr�r
rrr
r�sz+_ExecutorManagerThread.get_n_children_alive)rrrrr�r{r|r~r�r}r�r�r�r�rLrrrBr
rjs+ 
&rjc	Cshtrtrtt��dazt�d�}Wnttfy:YdS0|dkrHdS|dkrTdSd|att��dS)NT�SC_SEM_NSEMS_MAX����z@system provides too few semaphores (%d available, 256 necessary))�_system_limits_checked�_system_limited�NotImplementedErrorrc�sysconf�AttributeError�
ValueError)Z	nsems_maxrrr
�_check_system_limitss �r�ccs&|D]}|��|r|��VqqdSr)�reverserF)�iterableZelementrrr
�_chain_from_iterable_of_lists,sr�c@seZdZdS)r�N)rrrrrrr
r�8sr�cs~eZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Ze	j
jje_ddd��fdd�
Zddd�dd�Z
e	j
j
je
_�ZS)�ProcessPoolExecutorNrcCsJt�|dur6t��pd|_tjdkrntt|j�|_n8|dkrHtd��n tjdkrh|tkrhtdt����||_|dur~t	�
�}||_|jjdd�dk|_
|dur�t|�s�td	��||_||_d|_i|_d|_t��|_t�d�|_d|_d|_i|_d|_t�|_|jt }t!||j|j|j|jd
�|_"d|j"_#|�$�|_%t&�'�|_(dS)Nr!Zwin32rz"max_workers must be greater than 0zmax_workers must be <= F)Z
allow_none�forkzinitializer must be a callable)rAr=r>r?rT))r�rc�	cpu_count�_max_workers�sys�platform�min�_MAX_WINDOWS_WORKERSr�rZget_context�_mp_contextZget_start_method�#_safe_to_dynamically_spawn_children�callable�	TypeError�_initializer�	_initargs�_executor_manager_threadrsr��	threadingZLockroZ	Semaphorerr��_queue_countryr�rrn�EXTRA_QUEUED_CALLSr<ruZ
_ignore_epipeZSimpleQueuervr�rrw)rZmax_workersZ
mp_contextrfrgZ
queue_sizerrr
r@sZ

�

���


�
zProcessPoolExecutor.__init__cCs<|jdur8|js|��t|�|_|j��|jt|j<dSr)r�r��_launch_processesrj�startrnrr
rrr
�_start_executor_manager_thread�s


�z2ProcessPoolExecutor._start_executor_manager_threadcCs2|jjdd�rdSt|j�}||jkr.|��dS)NF)Zblocking)r�acquire�lenrsr��_spawn_process)rZ
process_countrrr
�_adjust_process_count�s


z)ProcessPoolExecutor._adjust_process_countcCs$tt|j�|j�D]}|��qdSr)r�r�rsr�r�)rrrrr
r��sz%ProcessPoolExecutor._launch_processescCs8|jjt|j|j|j|jfd�}|��||j|j	<dS)N)�targetr4)
r�ZProcessrirurvr�r�r�rs�pidr�rrr
r��s��z"ProcessPoolExecutor._spawn_processcOs�|j��|jrt|j��|jr&td��tr2td��t��}t||||�}||j	|j
<|j�|j
�|j
d7_
|j
��|jr�|��|��|Wd�S1s�0YdS)Nz*cannot schedule new futures after shutdownz6cannot schedule new futures after interpreter shutdownr!)ror�r�r��RuntimeErrorrrZFuturer1ryr�rwr[rnrr�r�r�)rr3r4r5�f�wrrr
�submit�s"

zProcessPoolExecutor.submitr!)�timeoutrQcs:|dkrtd��t�jtt|�t|d|i�|d�}t|�S)Nr!zchunksize must be >= 1.rQ)r�)r�r@�maprrYrUr�)rr3r�rQrRZresultsrBrr
r��s�zProcessPoolExecutor.mapTF)�cancel_futurescCs�|j�0||_d|_|jdur(|j��Wd�n1s<0Y|jdur^|r^|j��d|_d|_|jdur�|r�|j�	�d|_d|_
d|_dSr)ror�r�rnrr�rrurvrrs)rr�r�rrr
�shutdown�s
(

zProcessPoolExecutor.shutdown)NNNr)T)rrrrr�r�r�r�r�r�Executor�__doc__r�r�rLrrrBr
r�?s�
U

r�)NN)0�
__author__rcZconcurrent.futuresrr�ZmultiprocessingrZmultiprocessing.connectionZmultiprocessing.queuesrr�rp�	functoolsrrOr�r)�WeakKeyDictionaryrrrr Z_register_atexitr�r��	Exceptionr#r'r.�objectr1r7r;r<rUrYr^riZThreadrjr�r�r�r�ZBrokenExecutorr�r�r�rrrr
�<module>.sN



)