Your IP : 18.116.47.194


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

�
e f�#�@sydddgZddlZddlZddlZddlZddlmZyejjej	��Z
Wnek
r�dZ
YnXdd�Zdd�Z
dd	�ZGd
d�de�ZGdd�de�ZGd
d�de�Ze�aejd�ae�a[iZxSeejj��D]<\ZZedd�dkr,dekr,eee<q,q,We�ZdS)�BaseProcess�current_process�active_children�N)�WeakSetcCstS)z@
    Return process object representing the current process
    )�_current_process�rr�</opt/alt/python34/lib64/python3.4/multiprocessing/process.pyr#scCst�tt�S)zN
    Return list of process objects corresponding to live child processes
    )�_cleanup�list�	_childrenrrrrr)scCs@x9tt�D]+}|jj�dk	r
tj|�q
q
WdS)N)r
r�_popen�poll�discard)�prrrr	4sr	c	@sKeZdZdZdd�Zdddfidddd�Zdd	�Zd
d�Zdd
�Zddd�Z	dd�Z
edd��Zej
dd��Zedd��Zej
dd��Zedd��Zej
dd��Zedd��Zedd��ZeZedd ��Zd!d"�Zd#d$�ZdS)%rz�
    Process objects represent activity that is run in a separate process

    The class is analogous to `threading.Thread`
    cCs
t�dS)N)�NotImplementedError)�selfrrr�_PopenDszBaseProcess._PopenN�daemoncCs�|dkstd��tt�}tj|f|_tjj�|_tj�|_	d|_
||_t|�|_
t|�|_|p�t|�jddjdd�|jD��|_|dk	r�||_ntj|�dS)Nz#group argument must be None for now�-�:css|]}t|�VqdS)N)�str)�.0�irrr�	<genexpr>Ssz'BaseProcess.__init__.<locals>.<genexpr>)�AssertionError�next�_process_counterr�	_identity�_config�copy�os�getpid�_parent_pidr�_target�tuple�_args�dict�_kwargs�type�__name__�join�_namer�	_dangling�add)r�group�target�name�args�kwargsr�countrrr�__init__Gs		#zBaseProcess.__init__cCs&|jr"|j|j|j�ndS)zQ
        Method to be run in sub-process; can be overridden in sub-class
        N)r#r%r')rrrr�runXs	zBaseProcess.runcCs�|jdkstd��|jtj�ks<td��tjjd�s[td��t�|j	|�|_|jj
|_tj
|�dS)z%
        Start child process
        Nzcannot start a process twicez:can only start a process object created by current processrz3daemonic processes are not allowed to have children)rrr"r r!rr�getr	r�sentinel�	_sentinelrr-)rrrr�start_s		zBaseProcess.startcCs|jj�dS)zT
        Terminate process; sends SIGTERM signal or uses TerminateProcess()
        N)r�	terminate)rrrrr:mszBaseProcess.terminatecCsn|jtj�ks!td��|jdk	s<td��|jj|�}|dk	rjtj|�ndS)z5
        Wait until child process terminates
        zcan only join a child processNzcan only join a started process)r"r r!rr�waitrr)rZtimeout�resrrrr*ss
!zBaseProcess.joincCsa|tkrdS|jtj�ks1td��|jdkrDdS|jj�|jjdkS)z1
        Return whether process is alive
        Tzcan only test a child processNF)rr"r r!rrr
�
returncode)rrrr�is_alive}s!
zBaseProcess.is_alivecCs|jS)N)r+)rrrrr0�szBaseProcess.namecCs(t|t�std��||_dS)Nzname must be a string)�
isinstancerrr+)rr0rrrr0�scCs|jjdd�S)z4
        Return whether process is a daemon
        rF)rr6)rrrrr�szBaseProcess.daemoncCs,|jdkstd��||jd<dS)z1
        Set whether process is a daemon
        Nzprocess has already startedr)rrr)rZdaemonicrrrr�scCs|jdS)N�authkey)r)rrrrr@�szBaseProcess.authkeycCst|�|jd<dS)z2
        Set authorization key of process
        r@N)�AuthenticationStringr)rr@rrrr@�scCs#|jdkr|jS|jj�S)zM
        Return exit code of process or `None` if it has yet to stop
        N)rr
)rrrr�exitcode�szBaseProcess.exitcodecCs-|tkrtj�S|jo(|jjSdS)zU
        Return identifier (PID) of process or `None` if it has yet to start
        N)rr r!r�pid)rrrr�ident�s
zBaseProcess.identcCs0y|jSWntk
r+td��YnXdS)z{
        Return a file descriptor (Unix) or handle (Windows) suitable for
        waiting for process termination.
        zprocess not startedN)r8�AttributeError�
ValueError)rrrrr7�s
zBaseProcess.sentinelcCs�|tkrd}n]|jtj�kr3d}n?|jdkrKd}n'|jj�dk	rl|j}nd}t|�tkr�|dkr�d}q�dt	j
||�}ndt|�j|j||j
r�dp�d	fS)
NZstarted�unknown�initialrZstoppedzstopped[%s]z<%s(%s, %s%s)>z daemon�)rr"r r!rr
rBr(�int�_exitcode_to_namer6r)r+r)rZstatusrrr�__repr__�s				zBaseProcess.__repr__c(Cs�ddlm}m}z�y�|jdk	r>|j|j�ntjd�at�a	t
jdk	r�y#t
jj�t
tj�t
_Wq�ttfk
r�Yq�Xnt}|az|jj�|j�Wd~X|jd�z|j�d}Wd|j�XWn�tk
r�}zd|js+d}nMt|jdt�rQ|jd}n't
jjt|jd�d�d}WYdd}~Xn;d}ddl }t
jjd|j!�|j"�YnXWd|jd|�t
j#j$�t
jj$�X|S)N�)�util�contextz child process calling self.run()r�
zProcess %s:
z process exiting with exitcode %d)%rIrNrOZ
_start_methodZ_force_start_method�	itertoolsr3r�setr�sys�stdin�close�openr �devnull�OSErrorrFrZ_finalizer_registry�clearZ_run_after_forkers�infor5Z_exit_function�
SystemExitr1r?rJ�stderr�writer�	tracebackr0�	print_exc�stdout�flush)rrNrOZold_processrB�er^rrr�
_bootstrap�sN	




		!
zBaseProcess._bootstrap)r)�
__module__�__qualname__�__doc__rr4r5r9r:r*r>�propertyr0�setterrr@rBrDrCr7rLrcrrrrr>s*
	
c@seZdZdd�ZdS)rAcCsAddlm}|�dkr.td��ntt|�ffS)NrM)�get_spawning_popenzJPickling an AuthenticationString object is disallowed for security reasons)rOri�	TypeErrorrA�bytes)rrirrr�
__reduce__s
zAuthenticationString.__reduce__N)r)rdrerlrrrrrAsrAc@seZdZdd�ZdS)�_MainProcesscCsNf|_d|_d|_d|_ittjd��d6dd6|_dS)NZMainProcess� r@z/mpZ	semprefix)rr+r"rrAr �urandomr)rrrrr4*s				z_MainProcess.__init__N)r)rdrer4rrrrrm(srmrM�ZSIG�_) �__all__r rS�signalrQ�_weakrefsetr�path�abspath�getcwdZORIGINAL_DIRrXrrr	�objectrrkrArmrr3rrRrrKr
�__dict__�itemsr0Zsignumr,rrrr�<module>
s0

�		""

?>