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



]N@sdZddlZddlZddlmZddlZddlmZddlZddlmZddl	m
Z
ddlZddlZddl
mZddlZddlZejZdad	d
ZdZGdd
d
eZGdddZddZGdddeZGdddeZGdddeZddZddZddZ ddZ!d d!Z"da#da$d"d#Z%Gd$d%d%e&Z'Gd&d'd'ej(Z)ej*edS)(z"Brian Quinlan (brian@sweetapp.com)N)_base)Full)SimpleQueue)wait)partialFcCsadattj}x!|D]\}}|jdqWx|D]\}}|jqCWdS)NT)	_shutdownlist_threads_queuesitemsputjoin)r
tqr,/opt/alt/python35/lib64/python3.5/process.py_python_exitOsrc@s(eZdZddZddZdS)_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(eZdZddZddZdS)_ExceptionWithTracebackcCsDtjt|||}dj|}||_d||_dS)Nz

"""
%s""")	tracebackformat_exceptiontyper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@seZdZddZdS)	_WorkItemcCs(||_||_||_||_dS)N)futurefnargskwargs)rr%r&r'r(rrrrts			z_WorkItem.__init__N)rrrrrrrrr$ssr$c@s"eZdZddddZdS)_ResultItemNcCs||_||_||_dS)N)work_id	exceptionresult)rr*r+r,rrrr{s		z_ResultItem.__init__)rrrrrrrrr)zsr)c@seZdZddZdS)	_CallItemcCs(||_||_||_||_dS)N)r*r&r'r()rr*r&r'r(rrrrs			z_CallItem.__init__N)rrrrrrrrr-sr-cgs>t|}x+ttj||}|s1dS|VqWdS)N)ziptuple	itertoolsislice)	chunksize	iterablesitchunkrrr_get_chunkssr6csfdd|DS)Ncsg|]}|qSrr).0r')r&rr
<listcomp>s	z"_process_chunk.<locals>.<listcomp>r)r&r5r)r&r_process_chunks	r9cCsx|jdd}|dkr8|jtjdSy|j|j|j}WnStk
r}z3t||j	}|jt
|jd|WYdd}~XqX|jt
|jd|qWdS)NblockTr+r,)getrosgetpidr&r'r(
BaseExceptionr
__traceback__r)r*)
call_queueresult_queue	call_itemrer rrr_process_workers
/rEcCsx|jrdSy|jdd}Wntjk
rDdSYqX||}|jjr|jt||j|j	|j
ddq||=qqWdS)Nr:FT)fullr;queueEmptyr%set_running_or_notify_cancelrr-r&r'r()pending_work_itemswork_idsr@r*	work_itemrrr_add_call_item_to_queues 	

rMcsdfdd}fdd}|j}xt||ddjD}	t|g|	}
||
kr|j}n|dk	rd_d_dx3|jD]%\}}
|
jj	t
d~
qW|jxjD]}|jq
W|dSt
|trej|}|js|dSnb|dk	r|j|jd}
|
dk	r|jr|
jj	|jn|
jj|j~
||ry|s|dSWntk
rYnXdq9WdS)	NcstpdkpjS)N)r_shutdown_threadr)executorrr
shutting_downsz/_queue_management_worker.<locals>.shutting_downcsutddjD}x$td|D]}jdq/WjxjD]}|jq]WdS)Ncss|]}|jVqdS)N)is_alive)r7prrr	<genexpr>szD_queue_management_worker.<locals>.shutdown_worker.<locals>.<genexpr>r)sumvaluesrange
put_nowaitcloser)nb_children_aliveirR)r@	processesrrshutdown_workers
z1_queue_management_worker.<locals>.shutdown_workercSsg|]}|jqSr)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.)_readerrMrUrrecv_brokenrNr
r%
set_exceptionBrokenProcessPoolclear	terminate
isinstanceintpoprr*r+
set_resultr,r)executor_referencer[rJwork_ids_queuer@rArPr\reader	sentinelsreadyresult_itemr*rLrRr)r@rOr[r_queue_management_workersb					


			
rocCstrtrttdaytjd}Wnttfk
rOdSYnX|dkr`dS|dkrpdSd|attdS)NTSC_SEM_NSEMS_MAXrz@system provides too few semaphores (%d available, 256 necessary))_system_limits_checked_system_limitedNotImplementedErrorr<sysconfAttributeError
ValueError)	nsems_maxrrr_check_system_limitsQs	
rzc@seZdZdS)rbN)rrrrrrrrbhsrbcseZdZdddZddZddZdd	Zejjj	e_	d
dddfd
dZ
dddZejjj	e_	S)ProcessPoolExecutorNcCst|dkr+tjp"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_workersrxmultiprocessingQueueEXTRA_QUEUED_CALLS_call_queue
_ignore_epiper
_result_queuerG	_work_ids_queue_management_thread
_processesrN	threadingLock_shutdown_lockr`_queue_count_pending_work_items)rmax_workersrrrrps$	
					zProcessPoolExecutor.__init__c
Cs|jdd}|jdkr|jtjdtdtj|||j|j	|j
|j|jf|_d|j_|jj
|jt|j<dS)NcSs|jddS)N)r)_rrrr
weakref_cbszFProcessPoolExecutor._start_queue_management_thread.<locals>.weakref_cbtargetr'T)rr_adjust_process_countrThreadroweakrefrefrrrrdaemonstartr	)rrrrr_start_queue_management_threads
	
z2ProcessPoolExecutor._start_queue_management_threadcCshxatt|j|jD]D}tjdtd|j|jf}|j	||j|j
<qWdS)Nrr')rVlenrr}r~ProcessrErrrpid)rrrRrrrrs"	
z)ProcessPoolExecutor._adjust_process_countcOs|j|jrtd|jr4tdtj}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)rr`rbrNRuntimeErrorrFuturer$rrrrrr)rr&r'r(fwrrrsubmits
		
zProcessPoolExecutor.submittimeoutr2rcsX|dkrtdtjtt|t|d|d|}tjj|S)Nrzchunksize must be >= 1.r2r)	rxsupermaprr9r6r0chain
from_iterable)rr&rr2r3results)	__class__rrrs	zProcessPoolExecutor.mapTc	Csn|jd|_WdQRX|jrF|jjd|rF|jjd|_d|_d|_d|_dS)NT)rrNrrrrrr)rrrrrshutdowns
	
			zProcessPoolExecutor.shutdown)rrrrrrrrExecutor__doc__rrrr)rrr{os(	r{)+
__author__atexitr<concurrent.futuresrrGrr~rmultiprocessing.connectionrrr	functoolsrr0rWeakKeyDictionaryr	rrr	Exceptionrrr!objectr$r)r-r6r9rErMrorsrtrzrrbrr{registerrrrr<module>.sD
		%s
Back to Directory File Manager