AlkantarClanX12

Your IP : 3.133.148.76


Current Path : /opt/alt/python37/lib64/python3.7/multiprocessing/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/multiprocessing/__pycache__/forkserver.cpython-37.opt-2.pyc

B

YI~dq0�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddl	mZddlm
Z
ddl	mZddl	mZddl	mZd	d
ddgZd
Ze�d�ZGdd�de�Zddd�Zdd�Zdd�Zdd�Ze�ZejZejZejZejZdS)�N�)�
connection)�process)�	reduction)�semaphore_tracker)�spawn)�util�ensure_running�get_inherited_fds�connect_to_new_process�set_forkserver_preload��qc@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�
ForkServercCs.d|_d|_d|_d|_t��|_dg|_dS)N�__main__)�_forkserver_address�_forkserver_alive_fd�_forkserver_pid�_inherited_fds�	threadingZLock�_lock�_preload_modules)�self�r�?/opt/alt/python37/lib64/python3.7/multiprocessing/forkserver.py�__init__"s
zForkServer.__init__c	Cs|j�|��WdQRXdS)N)r�_stop_unlocked)rrrr�_stop*szForkServer._stopcCsJ|jdkrdSt�|j�d|_t�|jd�d|_t�|j�d|_dS)Nr)r�os�closer�waitpid�unlinkr)rrrrr/s
zForkServer._stop_unlockedcCs&tdd�|jD��std��||_dS)Ncss|]}t|�tkVqdS)N)�type�str)�.0�modrrr�	<genexpr>?sz4ForkServer.set_forkserver_preload.<locals>.<genexpr>z&module_names must be a list of strings)�allr�	TypeError)rZ
modules_namesrrrr=sz!ForkServer.set_forkserver_preloadcCs|jS)N)r)rrrrr
CszForkServer.get_inherited_fdsc
Cs�|��t|�dtkr td��t�tj���}|�|j�t�	�\}}t�	�\}}|||j
t��g}||7}z<yt
�||�||fSt�|�t�|��YnXWdt�|�t�|�XWdQRXdS)N�ztoo many fds)r	�len�MAXFDS_TO_SEND�
ValueError�socket�AF_UNIXZconnectrr�piperrZgetfdrZsendfdsr)r�fdsZclientZparent_r�child_w�child_rZparent_wZallfdsrrrrKs&



z!ForkServer.connect_to_new_processcs�|j��tt��|jdk	rVt�|jtj�\}}|s8dSt�|j�d|_	d|_d|_d}|j
r�ddh�t�d�}�fdd�|�
�D�}ni}t�tj���}t�d�}|�|�t�|�s�t�|d�|��t��\}}ztyV|��|g}	||��||j
|f;}t��}
|
gt��}|d	|g7}t�|
||	�}Wnt�|��YnXWdt�|�X||_	||_||_WdQRXWdQRXdS)
NzCfrom multiprocessing.forkserver import main; main(%d, %d, %r, **%r)�	main_path�sys_path�ignorecsi|]\}}|�kr||�qSrr)r$�x�y)�desired_keysrr�
<dictcomp>�sz-ForkServer.ensure_running.<locals>.<dictcomp>r.i�z-c)rrr	rrr �WNOHANGrrrrrZget_preparation_data�itemsr-r.rZarbitrary_addressZbindrZis_abstract_socket_namespace�chmodZlistenr/�filenoZget_executableZ_args_from_interpreter_flagsZspawnv_passfds)r�pid�status�cmd�data�listenerZaddress�alive_rZalive_wZfds_to_passZexe�argsr)r8rr	hsL






zForkServer.ensure_runningN)
�__name__�
__module__�__qualname__rrrrr
rr	rrrrr srcCs�|rhd|kr8|dk	r8dt��_zt�|�Wdt��`Xx.|D]&}yt|�Wq>tk
rbYq>Xq>Wt��t	�
�\}}t	�|d�t	�|d�dd�}tj
|tjtji}	dd�|	��D�}
t�|�i}tjtj|d���}t�����}
|��t_|
�|tj�|
�|tj�|
�|tj��x��yrx d	d
�|
��D�}|�r,P�q,W||k�rZt�||k�rJt	�|d�x�yt	�dt	j�\}}Wnt k
�r�PYnX|d
k�r�P|�!|d�}|dk	�r6t	�"|��r�t	�#|�}n&t	�$|��s�t%d�&||���t	�'|�}yt(||�Wnt)k
�r(YnXt	�*|�nt+�,d|��qrW||k�r�|�-�d
��0}t.�/|t0d�}t1|�t0k�r�t2d�&t1|����|^}}}|�*�t	�3�}|d
k�r<d}zpy<|�*�|
�*�||||g}|�4|�5��t6||||
�}Wn.t7k
�r(t8j9t8�:��t8j;�<�YnXWdt	�=|�XnRyt(||�Wnt)k
�r`YnX|||<t	�*|�x|D]}t	�*|��qzWWdQRXWn4t>k
�r�}z|j?t?j@k�r��Wdd}~XYnX�q&WWdQRXWdQRXdS)NrTFcWsdS)Nr)Z_unusedrrr�sigchld_handler�szmain.<locals>.sigchld_handlercSsi|]\}}t�||�|�qSr)�signal)r$�sig�valrrrr9�szmain.<locals>.<dictcomp>)r=cSsg|]\}}|j�qSr)Zfileobj)r$�keyZeventsrrr�
<listcomp>�szmain.<locals>.<listcomp>i���rzChild {0:n} status is {1:n}z.forkserver: waitpid returned unexpected pid %drzToo many ({0:n}) fds to send)ArZcurrent_processZ_inheritingrZimport_main_path�
__import__�ImportErrorrZ_close_stdinrr/�set_blockingrI�SIGCHLD�SIGINT�SIG_IGNr;�
set_wakeup_fdr-r.�	selectorsZDefaultSelectorZgetsockname�_forkserverr�registerZ
EVENT_READZselect�
SystemExit�readr r:�ChildProcessError�pop�WIFSIGNALED�WTERMSIG�	WIFEXITED�AssertionError�format�WEXITSTATUS�write_signed�BrokenPipeErrorr�warnings�warnZacceptrZrecvfdsr+r*�RuntimeError�fork�extend�values�
_serve_one�	Exception�sys�
excepthook�exc_info�stderr�flush�_exit�OSError�errnoZECONNABORTED)Zlistener_fdrCZpreloadr3r4�modnameZsig_rZsig_wrH�handlersZold_handlersZ	pid_to_fdrBZselectorZrfdsr>�stsr1�
returncode�sr0r2�code�
unused_fds�fd�errr�main�s�

















r~cCsdt�d�x |��D]\}}t�||�qWx|D]}t�|�q2W|^t_tj_	t_
t�|�}|S)NrN)
rIrUr;rrrWrrZ_semaphore_trackerZ_fdrr�_main)r2r0r{rvrJrKr|rzrrrrk0s


rkcCsRd}tj}x8t|�|krBt�||t|��}|s8td��||7}qWt�|�dS)N�zunexpected EOFr)�
SIGNED_STRUCT�sizer*rrZ�EOFError�unpack)r|rA�lengthryrrr�read_signedFsr�cCs@t�|�}x0|r:t�||�}|dkr,td��||d�}qWdS)Nrzshould not get here)r��packr�writerg)r|�n�msg�nbytesrrrrcPs
rc)NN) rtrrVrIr-�structrmrre�rr�contextrrrr�__all__r+�Structr��objectrr~rkr�rcrWr	r
rrrrrr�<module>s<