AlkantarClanX12

Your IP : 18.188.154.238


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-1.pyc

B

� fq0�@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)z>Set list of module names to try to load in forkserver process.css|]}t|�tkVqdS)N)�type�str)�.0�modrrr�	<genexpr>?sz4ForkServer.set_forkserver_preload.<locals>.<genexpr>z&module_names must be a list of stringsN)�allr�	TypeError)rZ
modules_namesrrrr=sz!ForkServer.set_forkserver_preloadcCs|jS)z�Return list of fds inherited from parent process.

        This returns None if the current process was not started by fork
        server.
        )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)a;Request forkserver to create a child process.

        Returns a pair of fds (status_r, data_w).  The calling process can read
        the child process's pid and (eventually) its returncode from status_r.
        The calling process should write to data_w the pickled preparation and
        process data.
        �ztoo many fdsN)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)z�Make sure that a fork server is running.

        This can be called from any process.  Note that usually a child
        process will just reuse the forkserver started by its parent, so
        ensure_running() will do nothing.
        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�pidZstatus�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|dk�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�}|dk�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)zRun forkserver.rNTFcWsdS)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_blockingrH�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_fdrBZpreloadr3r4�modnameZsig_rZsig_wrG�handlersZold_handlersZ	pid_to_fdrAZselectorZrfdsr>�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)NrM)
rHrTr;rrrVrrZ_semaphore_trackerZ_fdrr�_main)r2r0rzrurIrJr{ryrrrrj0s


rjcCsRd}tj}x8t|�|krBt�||t|��}|s8td��||7}qWt�|�dS)N�zunexpected EOFr)�
SIGNED_STRUCT�sizer*rrY�EOFErrorZunpack)r{r@�lengthrxrrr�read_signedFsr�cCs@t�|�}x0|r:t�||�}|dkr,td��||d�}qWdS)Nrzshould not get here)r�Zpackr�writerf)r{�n�msg�nbytesrrrrbPs
rb)NN) rsrrUrHr-Zstructrlrrd�rr�contextrrrr�__all__r+ZStructr��objectrr}rjr�rbrVr	r
rrrrrr�<module>s<