Your IP : 3.145.106.176


Current Path : /opt/alt/python34/lib64/python3.4/multiprocessing/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/multiprocessing/__pycache__/util.cpython-34.pyo

�
e f{)�@s<ddlZddlZddlZddlZddlZddlmZddlmZddddd	d
ddd
ddddddgZ	dZ
dZdZdZ
dZdZdZdadadd�Zdd�Zdd�Zdd�Zdd	�Zdd d
�Zd!d�Zej�Zej�Zd"d#�Zd$d�ZiZ ej�Z!Gd%d�de"�Z#dd&d'�Z$d(d
�Z%da&eee$ej'ej(d)d*�Z)ej*e)�Gd+d�de"�Z+Gd,d�dej,�Z-yej.d-�Z/Wne0k
rd.Z/YnXd/d�Z1d0d1�Z2dS)2�N)�_args_from_interpreter_flags�)�process�	sub_debug�debug�info�sub_warning�
get_logger�
log_to_stderr�get_temp_dir�register_after_fork�
is_exiting�Finalize�ForkAwareThreadLock�ForkAwareLocal�close_all_fds_except�SUBDEBUG�
SUBWARNING��
��Zmultiprocessingz+[%(levelname)s/%(processName)s] %(message)sFcGs trtjt||�ndS)N)�_logger�logr)�msg�args�r�9/opt/alt/python34/lib64/python3.4/multiprocessing/util.pyr+scGs trtjt||�ndS)N)rr�DEBUG)rrrrrr/scGs trtjt||�ndS)N)rr�INFO)rrrrrr3scGs trtjt||�ndS)N)rrr)rrrrrr7sc
Cs�ddl}|j�z�ts�|jt�adt_ttd�rctjt	�tj
t	�q�tjjt	fif�tjj
t	fif�nWd|j�XtS)z0
    Returns logger used by multiprocessing
    rN�
unregister)�loggingZ_acquireLockrZ	getLogger�LOGGER_NAMEZ	propagate�hasattr�atexitr �_exit_function�registerZ
_exithandlers�remove�appendZ_releaseLock)r!rrrr	;s
	
 cCsjddl}t�}|jt�}|j�}|j|�|j|�|r`|j|�ndat	S)zB
    Turn on logging and add a handler which prints to stderr
    rNT)
r!r	Z	Formatter�DEFAULT_LOGGING_FORMATZ
StreamHandlerZsetFormatterZ
addHandlerZsetLevel�_log_to_stderrr)�levelr!ZloggerZ	formatterZhandlerrrrr
Vs	

cCs�tj�jjd�}|dkr�ddl}ddl}|jdd�}td|�td|j	d|gdd	�|tj�jd<n|S)
N�tempdirr�prefixzpymp-zcreated temp directory %sr�exitpriority�di����)
r�current_processZ_config�get�shutil�tempfileZmkdtemprrZrmtree)r,r2r3rrrrls
cCs�ttj��}|j�x`|D]X\\}}}}y||�Wq#tk
rz}ztd|�WYdd}~Xq#Xq#WdS)Nz after forker raised exception %s)�list�_afterfork_registry�items�sort�	Exceptionr)r6�indexZident�func�obj�errr�_run_after_forkers~s
r=cCs#|ttt�t|�|f<dS)N)r5�next�_afterfork_counter�id)r;r:rrrr�sc@sjeZdZdZfdddd�Zdeeejdd�Z	dd�Z
d	d
�Zdd�ZdS)
rzA
    Class which supports object finalization using weakrefs
    NcCsz|dk	r$tj||�|_n||_||_|p?i|_|tt�f|_t	j
�|_|t|j<dS)N)
�weakref�ref�_weakref�	_callback�_args�_kwargsr>�_finalizer_counter�_key�os�getpid�_pid�_finalizer_registry)�selfr;�callbackr�kwargsr.rrr�__init__�s		zFinalize.__init__c
Cs�y||j=Wntk
r,|d�Yn�X|j|�krR|d�d}n4|d|j|j|j�|j|j|j�}d|_|_|_|_|_|SdS)zQ
        Run the callback unless it has already been called or cancelled
        zfinalizer no longer registeredz+finalizer ignored because different processNz/finalizer calling %s with args %s and kwargs %s)rH�KeyErrorrKrDrErFrC)rM�wrrLrrJ�resrrr�__call__�s

	%zFinalize.__call__cCsLyt|j=Wntk
r"Yn&Xd|_|_|_|_|_dS)z3
        Cancel finalization of the object
        N)rLrHrQrCrDrErF)rMrrr�cancel�s

zFinalize.cancelcCs
|jtkS)zS
        Return whether this finalizer is still waiting to invoke callback
        )rHrL)rMrrr�still_active�szFinalize.still_activec
Cs�y|j�}Wnttfk
r0d}YnX|dkrAdSdt|jd|j�}|jr�|dt|j�7}n|jr�|dt|j�7}n|jddk	r�|dt|jd�7}n|dS)	Nz<Finalize object, dead>z<Finalize object, callback=%s�__name__z, args=z	, kwargs=rz, exitprority=�>)	rC�AttributeError�	TypeError�getattrrDrE�strrFrH)rMr;�xrrr�__repr__�s		zFinalize.__repr__)
rW�
__module__�__qualname__�__doc__rPrLrrIrJrTrUrVr^rrrrr�scs�tdkrdS�dkr+dd��n�fdd���fdd�ttj��D�}|jdd�xW|D]O\}}td	|�y|�Wqytk
r�d
dl}|j�YqyXqyW�dkr�tj�ndS)z�
    Run all finalizers whose exit priority is not None and at least minpriority

    Finalizers with highest priority are called first; finalizers with
    the same priority will be called in reverse order of creation.
    NcSs|dddk	S)Nrr)�prrr�<lambda>�sz!_run_finalizers.<locals>.<lambda>cs&|dddk	o%|dd�kS)Nrr)rb)�minpriorityrrrc�scs"g|]}�|�r|�qSrr)�.0r])�frr�
<listcomp>�s	z#_run_finalizers.<locals>.<listcomp>�reverseTz
calling %sr)	rLr4r6r7rr8�	traceback�	print_exc�clear)rdr6�keyZ	finalizerrir)rfrdr�_run_finalizers�s %

rmcCstptdkS)z6
    Returns true if the process is shutting down
    N)�_exitingrrrrr
scCs�ts�da|d�|d�|d�|�dk	r�x:|�D]/}|jrC|d|j�|jj�qCqCWx.|�D] }|d|j�|j�q�Wn|d�|�ndS)NTzprocess shutting downz2running all "atexit" finalizers with priority >= 0rz!calling terminate() for daemon %szcalling join() for process %sz)running the remaining "atexit" finalizers)rnZdaemon�nameZ_popenZ	terminate�join)rrrm�active_childrenr0rbrrrr%s	


	
r%c@s(eZdZdd�Zdd�ZdS)rcCs|j�t|tj�dS)N)�_resetrr)rMrrrrPAs
zForkAwareThreadLock.__init__cCs1tj�|_|jj|_|jj|_dS)N)�	threadingZLock�_lock�acquire�release)rMrrrrrEszForkAwareThreadLock._resetN)rWr_r`rPrrrrrrr@sc@s(eZdZdd�Zdd�ZdS)rcCst|dd��dS)NcSs
|jj�S)N)�__dict__rk)r;rrrrcLsz)ForkAwareLocal.__init__.<locals>.<lambda>)r)rMrrrrPKszForkAwareLocal.__init__cCst|�ffS)N)�type)rMrrr�
__reduce__MszForkAwareLocal.__reduce__N)rWr_r`rPryrrrrrJs�SC_OPEN_MAX�cCset|�dtg}|j�x>tt|�d�D]&}tj||d||d�q7WdS)Nr���)r4�MAXFDr7�range�lenrI�
closerange)Zfds�irrrrYs
cCs�ddl}t|�}tj�\}}zM|j|tj|�gd|ddddddd	d
||ddd�SWdtj|�tj|�XdS)NrTrFr|r|r|r|r|r|)�_posixsubprocess�sortedrI�pipeZ	fork_exec�fsencode�close)�pathrZpassfdsr�Zerrpipe_readZ
errpipe_writerrr�spawnv_passfdsds
r�)3rI�	itertoolsrAr$rs�
subprocessr�r�__all__ZNOTSETrrrrr"r)rr*rrrrr	r
r�WeakValueDictionaryr5�countr?r=rrLrG�objectrrmr
rnrqr0r%r&rZlocalr�sysconfr}r8rr�rrrr�<module>
s`		R$	(





?>