Your IP : 3.145.105.199


Current Path : /opt/alt/python310/lib64/python3.10/concurrent/futures/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/concurrent/futures/__pycache__/process.cpython-310.opt-2.pyc

o

6��f�|�@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�A/opt/alt/python310/lib64/python3.10/concurrent/futures/process.py�__init__Csz_ThreadWakeup.__init__cCs(|jsd|_|j��|j��dSdS�NT)rr	�closerr
rrr
rGs

�z_ThreadWakeup.closecCs|js|j�d�dSdS)N�)rr	Z
send_bytesr
rrr
�wakeupMs�z_ThreadWakeup.wakeupcCs0|js|j��r|j��|j��sdSdSdS�N)rrZpollZ
recv_bytesr
rrr
�clearQs

��z_ThreadWakeup.clearN)�__name__�
__module__�__qualname__rrrrrrrr
rBs
rcCs@datt���}|D]\}}|��q
|D]\}}|��qdSr)�_global_shutdown�list�_threads_wakeups�itemsr�join)r�_�
thread_wakeup�trrr
�_python_exitWs

�r ��=c@�eZdZdd�Zdd�ZdS)�_RemoteTracebackcCs
||_dSr��tb)rr&rrr
rws
z_RemoteTraceback.__init__cCs|jSrr%r
rrr
�__str__ysz_RemoteTraceback.__str__N)rrrrr'rrrr
r$vsr$c@r#)�_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)rrrrr0rrrr
r(|sr(cCst|�|_|Sr)r$�	__cause__)r-r&rrr
r/�s
r/c@�eZdZdd�ZdS)�	_WorkItemcC�||_||_||_||_dSr)�future�fn�args�kwargs)rr5r6r7r8rrr
r��
z_WorkItem.__init__N�rrrrrrrr
r3��r3c@seZdZddd�ZdS)�_ResultItemNcCs||_||_||_dSr)�work_id�	exception�result)rr=r>r?rrr
r�s
z_ResultItem.__init__�NNr:rrrr
r<�sr<c@r2)�	_CallItemcCr4r)r=r6r7r8)rr=r6r7r8rrr
r�r9z_CallItem.__init__Nr:rrrr
rA�r;rAcs,eZdZ	d�fdd�	Z�fdd�Z�ZS)�
_SafeQueuercs&||_||_||_t�j||d�dS)N)�ctx)�pending_work_items�
shutdown_lockr�superr)r�max_sizerCrDrEr��	__class__rr
r�sz_SafeQueue.__init__cs�t|t�rHt�t|�||j�}td�d�|���|_	|j
�|jd�}|j
�
|j��Wd�n1s5wY|durF|j�|�dSdSt��||�dS)Nz

"""
{}"""r))�
isinstancerAr*r+r,r.r$�formatrr1rD�popr=rErrr5�
set_exceptionrF�_on_queue_feeder_error)r�e�objr&�	work_itemrHrr
rN�s
��z!_SafeQueue._on_queue_feeder_error)r)rrrrrN�
__classcell__rrrHr
rB�srBcgs.�	t|�}	tt�||��}|sdS|Vqr)�zip�tuple�	itertools�islice)�	chunksize�	iterables�it�chunkrrr
�_get_chunks�s��r[cs	�fdd�|D�S)Ncsg|]}�|��qSrr)�.0r7�r6rr
�
<listcomp>�sz"_process_chunk.<locals>.<listcomp>r)r6rZrr]r
�_process_chunk�sr_c
Csb	z
|�t|||d��WdSty0}zt||j�}|�t||d��WYd}~dSd}~ww)N)r?r>�r>)�putr<�
BaseExceptionr(r.)�result_queuer=r?r>rOr-rrr
�_sendback_result�s
� ��rdc
Cs�	|durz||�Wntytjjddd�YdSw	|jdd�}|dur2|�t���dSz|j|j	i|j
��}Wn ty^}zt||j�}t
||j|d�WYd}~nd}~wwt
||j|d�~~q)NzException in initializer:T)�exc_info��blockr`)r?)rbrZLOGGERZcritical�getra�os�getpidr6r7r8r(r.rdr=)�
call_queuerc�initializer�initargsZ	call_item�rrOr-rrr
�_process_worker�s0����rocsneZdZ	�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�dS1swYdS)Nz?Executor collected: triggering callback for QueueManager wakeup)r�util�debugr)rrrErrr
�
weakref_cbs
"�z3_ExecutorManagerThread.__init__.<locals>.weakref_cb)�_executor_manager_thread_wakeupr�_shutdown_lockrE�weakref�ref�executor_reference�
_processes�	processes�_call_queuerk�
_result_queuerc�	_work_ids�work_ids_queue�_pending_work_itemsrDrFr)r�executorrsrHrr
rs	
�z_ExecutorManagerThread.__init__cCs�	|��|��\}}}|r|�|�dS|dur-|�|�~|��}|dur,|j��~|��rB|��|��|j	sB|�
�dSqr)�add_call_item_to_queue�wait_result_broken_or_wakeup�terminate_broken�process_result_itemrx�_idle_worker_semaphore�release�is_shutting_down�flag_executor_shutting_downrD�join_executor_internals)r�result_item�	is_broken�causer�rrr
�run:s(


�z_ExecutorManagerThread.runcCs|	|j��rdSz	|jjdd�}WntjyYdSw|j|}|j��r8|jj	t
||j|j|j
�dd�n|j|=qq)NTFrf)rkZfullr~rh�queue�EmptyrDr5Zset_running_or_notify_cancelrarAr6r7r8)rr=rQrrr
r�_s(
�


���z-_ExecutorManagerThread.add_call_item_to_queuec

Cs�|jj}|jj}||g}dd�t|j���D�}tj�||�}d}d}d}||vrOz|�	�}d}Wn"t
yN}	zt�t
|	�|	|	j�}WYd}	~	nd}	~	ww||vrUd}|j�
|j��Wd�n1shwY|||fS)NcSsg|]}|j�qSr)Zsentinel�r\�prrr
r^�szG_ExecutorManagerThread.wait_result_broken_or_wakeup.<locals>.<listcomp>TF)rcrrrrz�valuesrZ
connection�waitZrecvrbr*r+r,r.rEr)
rZ
result_readerZ
wakeup_readerZreadersZworker_sentinelsZreadyr�r�r�rOrrr
r�vs, ���
z3_ExecutorManagerThread.wait_result_broken_or_wakeupcCszt|t�r|j�|�}|��|js|��dSdS|j�|jd�}|dur;|jr2|j	�
|j�dS|j	�|j�dSdSr)
rJ�intrzrLrr�rDr=r>r5rMZ
set_resultr?)rr�r�rQrrr
r��s
��z*_ExecutorManagerThread.process_result_itemcCs|��}tp|dup|jSr)rxr�_shutdown_thread)rr�rrr
r��s�z'_ExecutorManagerThread.is_shutting_downcCs�|��}|durd|_d|_d}td�}|dur$tdd�|��d��|_|j��D]\}}|j	�
|�~q)|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''')rx�_brokenr��BrokenProcessPoolr$rr1rDrr5rMrrzr�Z	terminater�)rr�r�Zbper=rQr�rrr
r��s"�

z'_ExecutorManagerThread.terminate_brokencCs�|��}|dur?d|_|jrAi}|j��D]
\}}|j��s"|||<q||_	z|j��Wn
t	j
y8Ynwq'd|_dSdSdS)NTF)rxr��_cancel_pending_futuresrDrr5Zcancelr~Z
get_nowaitr�r�)rr�Znew_pending_work_itemsr=rQrrr
r��s(
���
�z2_ExecutorManagerThread.flag_executor_shutting_downc	Cs�|��}d}||kr<|��dkr>t||�D]}z|j�d�|d7}Wqtjy/Ynw||kr@|��dksdSdSdSdS)Nrr!)�get_n_children_alive�rangerkZ
put_nowaitr�ZFull)rZn_children_to_stopZn_sentinels_sent�irrr
�shutdown_workers�s ����z'_ExecutorManagerThread.shutdown_workerscCsh|��|j��|j��|j�
|j��Wd�n1s!wY|j��D]}|��q+dSr)	r�rkrZjoin_threadrErrzr�r�rr�rrr
r�s

�
�z._ExecutorManagerThread.join_executor_internalscCstdd�|j��D��S)Ncss�|]}|��VqdSr)Zis_aliver�rrr
�	<genexpr>s�z>_ExecutorManagerThread.get_n_children_alive.<locals>.<genexpr>)�sumrzr�r
rrr
r�sz+_ExecutorManagerThread.get_n_children_alive)rrrrr�r�r�r�r�r�r�r�r�r�rRrrrHr
rps+%
&rpc	Cs�trtrtt��dazddl}Wn
tydatt��wzt�d�}Wnttfy1YdSw|dkr8dS|dkr>dSd|att��)NTrzxThis Python build lacks multiprocessing.synchronize, usually due to named semaphores being unavailable on this platform.�SC_SEM_NSEMS_MAX����z@system provides too few semaphores (%d available, 256 necessary))	�_system_limits_checked�_system_limited�NotImplementedErrorZmultiprocessing.synchronize�ImportErrorri�sysconf�AttributeError�
ValueError)�multiprocessingZ	nsems_maxrrr
�_check_system_limitss0����r�ccs,�	|D]}|��|r|��V|sqdSr)�reverserL)�iterableZelementrrr
�_chain_from_iterable_of_lists9s�
���r�c@seZdZdS)r�N)rrrrrrr
r�Esr�cs�eZdZ		ddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Ze	j
jje_ddd��fdd�
Zddd�dd�Z
e	j
j
je
_�ZS)�ProcessPoolExecutorNrcCsJ	t�|durt��p
d|_tjdkrtt|j�|_n|dkr$td��tjdkr4|tkr4tdt����||_|dur?t	�
�}||_|jjdd�dk|_
|durXt|�sXtd	��||_||_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)rGrCrDrErT))r�ri�	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_threadryr��	threadingZLockruZ	Semaphorer�r��_queue_countrr�rrt�EXTRA_QUEUED_CALLSrBr{Z
_ignore_epipeZSimpleQueuer|r�rr})rZmax_workersZ
mp_contextrlrmZ
queue_sizerrr
rMs\
��
��


�
zProcessPoolExecutor.__init__cCs@|jdur|js|��t|�|_|j��|jt|j<dSdSr)r�r��_launch_processesrp�startrtrr
rrr
�_start_executor_manager_thread�s


��z2ProcessPoolExecutor._start_executor_manager_threadcCs6|jjdd�r	dSt|j�}||jkr|��dSdS)NF)Zblocking)r��acquire�lenryr��_spawn_process)rZ
process_countrrr
�_adjust_process_count�s

�z)ProcessPoolExecutor._adjust_process_countcCs$tt|j�|j�D]}|��q	dSr)r�r�ryr�r�)rrrrr
r��s
�z%ProcessPoolExecutor._launch_processescCs8|jjt|j|j|j|jfd�}|��||j|j	<dS)N)�targetr7)
r�ZProcessror{r|r�r�r�ry�pidr�rrr
r��s��z"ProcessPoolExecutor._spawn_processcOs�|j�N|jrt|j��|jrtd��trtd��t��}t||||�}||j	|j
<|j�|j
�|j
d7_
|j
��|jrD|��|��|Wd�S1sTwYdS)Nz*cannot schedule new futures after shutdownz6cannot schedule new futures after interpreter shutdownr!)rur�r�r��RuntimeErrorrrZFuturer3rr�r}rartrr�r�r�)rr6r7r8�f�wrrr
�submit�s$

$�zProcessPoolExecutor.submitr!)�timeoutrWcs<	|dkr	td��t�jtt|�t|d|i�|d�}t|�S)Nr!zchunksize must be >= 1.rW)r�)r�rF�maprr_r[r�)rr6r�rWrXZresultsrHrr
r��s�zProcessPoolExecutor.mapTF)�cancel_futurescCs�|j�||_d|_|jdur|j��Wd�n1swY|jdur/|r/|j��d|_d|_|jdurA|rA|j�	�d|_d|_
d|_dSr)rur�r�rtrr�rr{r|rry)rr�r�rrr
�shutdowns 

��


zProcessPoolExecutor.shutdown)NNNr)T)rrrrr�r�r�r�r�r�Executor�__doc__r�r�rRrrrHr
r�Ls
�U

r�r@)0�
__author__riZconcurrent.futuresrr�r�rZmultiprocessing.connectionZmultiprocessing.queuesrr�rv�	functoolsrrUr�r*�WeakKeyDictionaryrrrr Z_register_atexitr�r��	Exceptionr$r(r/�objectr3r<rArBr[r_rdroZThreadrpr�r�r�r�ZBrokenExecutorr�r�r�rrrr
�<module>sR*



) 

?>