ok

Mini Shell

Direktori : /opt/alt/python35/lib64/python3.5/concurrent/futures/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/concurrent/futures/__pycache__/process.cpython-35.opt-2.pyc



���]�N�@s�dZddlZddlZddlmZddlZddlmZddlZddlmZddl	m
Z
ddlZddlZddl
mZddlZddlZej�Zdad	d
�ZdZGdd
�d
e�ZGdd�d�Zdd�ZGdd�de�ZGdd�de�ZGdd�de�Zdd�Zdd�Zdd�Z dd�Z!d d!�Z"da#da$d"d#�Z%Gd$d%�d%e&�Z'Gd&d'�d'ej(�Z)ej*e�dS)(z"Brian Quinlan (brian@sweetapp.com)�N)�_base)�Full)�SimpleQueue)�wait)�partialFcCsadattj��}x!|D]\}}|jd�qWx|D]\}}|j�qCWdS)NT)�	_shutdown�list�_threads_queues�items�put�join)r
�t�q�r�,/opt/alt/python35/lib64/python3.5/process.py�_python_exitOsr�c@s(eZdZdd�Zdd�ZdS)�_RemoteTracebackcCs
||_dS)N)�tb)�selfrrrr�__init__asz_RemoteTraceback.__init__cCs|jS)N)r)rrrr�__str__csz_RemoteTraceback.__str__N)�__name__�
__module__�__qualname__rrrrrrr`src@s(eZdZdd�Zdd�ZdS)�_ExceptionWithTracebackcCsDtjt|�||�}dj|�}||_d||_dS)N�z

"""
%s""")�	traceback�format_exception�typer�excr)rr rrrrrgs	z _ExceptionWithTraceback.__init__cCst|j|jffS)N)�_rebuild_excr r)rrrr�
__reduce__lsz"_ExceptionWithTraceback.__reduce__N)rrrrr"rrrrrfsrcCst|�|_|S)N)r�	__cause__)r rrrrr!osr!c@seZdZdd�ZdS)�	_WorkItemcCs(||_||_||_||_dS)N)�future�fn�args�kwargs)rr%r&r'r(rrrrts			z_WorkItem.__init__N)rrrrrrrrr$ssr$c@s"eZdZdddd�ZdS)�_ResultItemNcCs||_||_||_dS)N)�work_id�	exception�result)rr*r+r,rrrr{s		z_ResultItem.__init__)rrrrrrrrr)zsr)c@seZdZdd�ZdS)�	_CallItemcCs(||_||_||_||_dS)N)r*r&r'r()rr*r&r'r(rrrr�s			z_CallItem.__init__N)rrrrrrrrr-�sr-cgs>t|�}x+ttj||��}|s1dS|VqWdS)N)�zip�tuple�	itertools�islice)�	chunksize�	iterables�it�chunkrrr�_get_chunks�sr6cs�fdd�|D�S)Ncsg|]}�|��qSrr)�.0r')r&rr�
<listcomp>�s	z"_process_chunk.<locals>.<listcomp>r)r&r5r)r&r�_process_chunk�s	r9cCs�x�|jdd�}|dkr8|jtj��dSy|j|j|j�}WnStk
r�}z3t||j	�}|jt
|jd|��WYdd}~XqX|jt
|jd|��qWdS)N�blockTr+r,)�getr�os�getpidr&r'r(�
BaseExceptionr�
__traceback__r)r*)�
call_queue�result_queue�	call_item�r�er rrr�_process_worker�s
/rEcCs�x�|j�rdSy|jdd�}Wntjk
rDdSYqX||}|jj�r�|jt||j|j	|j
�dd�q||=qqWdS)Nr:FT)�fullr;�queue�Emptyr%�set_running_or_notify_cancelrr-r&r'r()�pending_work_items�work_idsr@r*�	work_itemrrr�_add_call_item_to_queue�s 	

rMcsd��fdd�}��fdd�}|j}x�t||��dd��j�D�}	t|g|	�}
||
kr�|j�}n�|���dk	r�d�_d�_d�x3|j�D]%\}}
|
jj	t
d��~
q�W|j�x�j�D]}|j�q
W|�dSt
|t�re�j|�}|j��s�|�dSnb|dk	r�|j|jd�}
|
dk	r�|jr�|
jj	|j�n|
jj|j�~
|��|�ry|s�|�dSWntk
rYnXd�q9WdS)	Ncstp�dkp�jS)N)r�_shutdown_threadr)�executorrr�
shutting_down�sz/_queue_management_worker.<locals>.shutting_downcsutdd��j�D��}x$td|�D]}�jd�q/W�j�x�j�D]}|j�q]WdS)Ncss|]}|j�VqdS)N)�is_alive)r7�prrr�	<genexpr>�szD_queue_management_worker.<locals>.shutdown_worker.<locals>.<genexpr>r)�sum�values�range�
put_nowait�closer)�nb_children_alive�irR)r@�	processesrr�shutdown_worker�s
z1_queue_management_worker.<locals>.shutdown_workercSsg|]}|j�qSr)�sentinel)r7rRrrrr8s	z,_queue_management_worker.<locals>.<listcomp>Tz^A process in the process pool was terminated abruptly while the future was running or pending.)�_readerrMrUr�recv�_brokenrNr
r%�
set_exception�BrokenProcessPool�clear�	terminate�
isinstance�int�poprr*r+�
set_resultr,r)�executor_referencer[rJ�work_ids_queuer@rArPr\�reader�	sentinels�ready�result_itemr*rLrRr)r@rOr[r�_queue_management_worker�sb					


			
rocCs�trtrtt��daytjd�}Wnttfk
rOdSYnX|dkr`dS|dkrpdSd|att��dS)NT�SC_SEM_NSEMS_MAXr�z@system provides too few semaphores (%d available, 256 necessary)���)�_system_limits_checked�_system_limited�NotImplementedErrorr<�sysconf�AttributeError�
ValueError)�	nsems_maxrrr�_check_system_limitsQs	
rzc@seZdZdS)rbN)rrrrrrrrbhsrbcs�eZdZddd�Zdd�Zdd�Zdd	�Zejjj	e_	d
ddd�fd
d�Z
ddd�Zejjj	e_	�S)�ProcessPoolExecutorNcCs�t�|dkr+tj�p"d|_n!|dkrCtd��||_tj|jt�|_d|j_	t
�|_tj�|_
d|_i|_d|_tj�|_d|_d|_i|_dS)Nrrz"max_workers must be greater than 0TF)rzr<�	cpu_count�_max_workersrx�multiprocessing�Queue�EXTRA_QUEUED_CALLS�_call_queue�
_ignore_epiper�
_result_queuerG�	_work_ids�_queue_management_thread�
_processesrN�	threading�Lock�_shutdown_lockr`�_queue_count�_pending_work_items)r�max_workersrrrrps$	
					zProcessPoolExecutor.__init__c
Cs�|jdd�}|jdkr�|j�tjdtdtj||�|j|j	|j
|j|jf�|_d|j_|jj
�|jt|j<dS)NcSs|jd�dS)N)r)�_rrrr�
weakref_cb�szFProcessPoolExecutor._start_queue_management_thread.<locals>.weakref_cb�targetr'T)r�r��_adjust_process_countr��Threadro�weakref�refr�r�r�r��daemon�startr	)rr�rrr�_start_queue_management_thread�s
	
z2ProcessPoolExecutor._start_queue_management_threadcCshxatt|j�|j�D]D}tjdtd|j|jf�}|j	�||j|j
<qWdS)Nr�r')rV�lenr�r}r~�ProcessrEr�r�r��pid)rr�rRrrrr��s"	
z)ProcessPoolExecutor._adjust_process_countcOs�|j��|jrtd��|jr4td��tj�}t||||�}||j|j	<|j
j|j	�|j	d7_	|jjd�|j
�|SWdQRXdS)NzKA child process terminated abruptly, the process pool is not usable anymorez*cannot schedule new futures after shutdownr)r�r`rbrN�RuntimeErrorr�Futurer$r�r�r�rr�r�)rr&r'r(�f�wrrr�submit�s
		
zProcessPoolExecutor.submit�timeoutr2rcsX|dkrtd��t�jtt|�t|d|�d|�}tjj|�S)Nrzchunksize must be >= 1.r2r�)	rx�super�maprr9r6r0�chain�
from_iterable)rr&r�r2r3�results)�	__class__rrr��s	zProcessPoolExecutor.mapTc	Csn|j�d|_WdQRX|jrF|jjd�|rF|jj�d|_d|_d|_d|_dS)NT)r�rNr�r�rrr�r�)rrrrr�shutdown�s
	
			zProcessPoolExecutor.shutdown)rrrrr�r�r�r�Executor�__doc__r�r�rr)r�rr{os(	r{)+�
__author__�atexitr<�concurrent.futuresrrGrr~r�multiprocessing.connectionrr�r��	functoolsrr0r�WeakKeyDictionaryr	rrr��	Exceptionrrr!�objectr$r)r-r6r9rErMrorsrtrzr�rbr�r{�registerrrrr�<module>.sD
		%s�

Zerion Mini Shell 1.0