Current File : //opt/alt/python35/lib64/python3.5/multiprocessing/__pycache__/process.cpython-35.opt-1.pyc
�q�\�#�@svdddgZddlZddlZddlZddlZddlmZyejjej ��Z
Wnek
r�dZ
YnXdd�Zdd�Z
dd �ZGd
d�de�ZGdd�de�ZGd
d�de�Ze�aejd�ae�a[iZxPeejj��D]9\ZZedd�dkr,dekr,eee<q,We�ZdS)�BaseProcess�current_process�active_children�N)�WeakSetcCstS)z@
Return process object representing the current process
)�_current_process�rr�</opt/alt/python35/lib64/python3.5/multiprocessing/process.pyr#scCst�tt�S)zN
Return list of process objects corresponding to live child processes
)�_cleanup�list� _childrenrrrrr)scCs=x6tt�D](}|jj�dk r
tj|�q
WdS)N)r
r�_popen�poll�discard)�prrrr 4sr c @sKeZdZdZdd�Zdddfidddd�Zdd �Zd
d�Zdd
�Zddd�Z dd�Z
edd��Zej
dd��Zedd��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�tt�}tj|f|_tjj�|_tj�|_d|_ ||_
t|�|_t
|�|_|p�t|�jddjdd�|jD��|_|dk r�||_tj|�dS)N�-�:css|]}t|�VqdS)N)�str)�.0�irrr� <genexpr>Ssz'BaseProcess.__init__.<locals>.<genexpr>)�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�dS)zQ
Method to be run in sub-process; can be overridden in sub-class
N)r"r$r&)rrrr�runXs zBaseProcess.runcCsKt�|j|�|_|jj|_|`|`|`tj |�dS)z%
Start child process
N)
r rr�sentinel� _sentinelr"r$r&rr,)rrrr�start_s
zBaseProcess.startcCs|jj�dS)zT
Terminate process; sends SIGTERM signal or uses TerminateProcess()
N)r� terminate)rrrrr8pszBaseProcess.terminatecCs/|jj|�}|dk r+tj|�dS)z5
Wait until child process terminates
N)r�waitrr)rZtimeout�resrrrr)vszBaseProcess.joincCs@|tkrdS|jdkr#dS|jj�|jjdkS)z1
Return whether process is alive
TNF)rrr
�
returncode)rrrr�is_alive�s
zBaseProcess.is_alivecCs|jS)N)r*)rrrrr/�szBaseProcess.namecCs
||_dS)N)r*)rr/rrrr/�scCs|jjdd�S)z4
Return whether process is a daemon
rF)r�get)rrrrr�szBaseProcess.daemoncCs||jd<dS)z1
Set whether process is a daemon
rN)r)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)rr
)rrrr�exitcode�szBaseProcess.exitcodecCs-|tkrtj�S|jo(|jjSdS)zU
Return identifier (PID) of process or `None` if it has yet to start
N)rrr 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)r6�AttributeError�
ValueError)rrrrr5�s
zBaseProcess.sentinelcCs�|tkrd}n]|jtj�kr3d}n?|jdkrKd}n'|jj�dk rl|j}nd}t|�tkr�|dkr�d}ndt j
||�}dt|�j|j||j
r�dp�d fS)
NZstarted�unknown�initialrZstoppedzstopped[%s]z<%s(%s, %s%s)>z daemon�)rr!rr rr
r@r'�int�_exitcode_to_namer=r(r*r)rZstatusrrr�__repr__�s zBaseProcess.__repr__c Cs�ddlm}m}zgy�|jdk r;|j|j�tjd�at�a |j
�t}|az|jj
�|j�Wd~X|jd�z|j�d}Wd|j�XWn�tk
rA}zd|js�d}nMt|jdt�r|jd}n'tjjt|jd�d�d}WYdd}~Xn;d}ddl}tjjd|j�|j�YnXWd|jd|�tjj�tjj�X|S)N�)�util�contextz child process calling self.run()r�
zProcess %s:
z process exiting with exitcode %d)rGrLrMZ
_start_methodZ_force_start_method� itertoolsr2r�setrZ_close_stdinrZ_finalizer_registry�clearZ_run_after_forkers�infor4Z_exit_function�
SystemExitr0�
isinstancerH�sys�stderr�writer� tracebackr/� print_exc�stdout�flush)rrLrMZold_processr@�erXrrr�
_bootstrap�sD
!
zBaseProcess._bootstrap)r(�
__module__�__qualname__�__doc__rr3r4r7r8r)r<�propertyr/�setterrr>r@rBrAr5rJr]rrrrr>s*
c@seZdZdd�ZdS)r?cCs>ddlm}|�dkr+td��tt|�ffS)NrK)�get_spawning_popenzJPickling an AuthenticationString object is disallowed for security reasons)rMrc� TypeErrorr?�bytes)rrcrrr�
__reduce__s
zAuthenticationString.__reduce__N)r(r^r_rfrrrrr?sr?c@seZdZdd�ZdS)�_MainProcesscCsLf|_d|_d|_d|_dttjd��ddi|_dS)NZMainProcessr>� Z semprefixz/mp)rr*r!rr?r�urandomr)rrrrr3(s z_MainProcess.__init__N)r(r^r_r3rrrrrg&srgrK�ZSIG�_) �__all__rrU�signalrO�_weakrefsetr�path�abspath�getcwdZORIGINAL_DIR�OSErrorrrr �objectrrer?rgrr2rrPrrIr
�__dict__�itemsr/Zsignumr+rrrr�<module>
s0
� ""