AlkantarClanX12

Your IP : 18.188.132.71


Current Path : /lib64/python3.8/multiprocessing/__pycache__/
Upload File :
Current File : //lib64/python3.8/multiprocessing/__pycache__/forkserver.cpython-38.pyc

U

e5d�0�@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)�resource_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�2/usr/lib64/python3.8/multiprocessing/forkserver.py�__init__"s
zForkServer.__init__c	Cs|j�|��W5QRXdS�N)r�_stop_unlockedrrrr�_stop*szForkServer._stopcCsV|jdkrdSt�|j�d|_t�|jd�d|_t�|j�sLt�|j�d|_dS)Nr)	r�os�closer�waitpidr�is_abstract_socket_namespacer�unlinkrrrrr/s
zForkServer._stop_unlockedcCs&tdd�|jD��std��||_dS)z>Set list of module names to try to load in forkserver process.css|]}t|�tkVqdSr)�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.
        )rrrrrr
DszForkServer.get_inherited_fdsc
Cs�|��t|�dtkr td��t�tj���}|�|j�t�	�\}}t�	�\}}|||j
t��g}||7}zNz&t�||�||fWW�4W5QR�St�
|�t�
|��YnXW5t�
|�t�
|�XW5QRXdS)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 �piperrZgetfdr!rZsendfds)r�fdsZclientZparent_r�child_w�child_rZparent_wZallfdsrrrrLs(�


z!ForkServer.connect_to_new_processcs�|j��~t��|jdk	r`t�|jtj�\}}|sBW5QR�dSt�|j�d|_	d|_d|_d}|j
r�ddh�t�d�}�fdd�|�
�D�}ni}t�tj���}t�d�}|�|�t�|�s�t�|d	�|��t��\}}ztzV|��|g}	||��||j
|f;}t��}
|
gt��}|d
|g7}t�|
||	�}Wnt�|��YnXW5t�|�X||_	||_||_W5QRXW5QRXdS)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�Zdesired_keysrr�
<dictcomp>�sz-ForkServer.ensure_running.<locals>.<dictcomp>r1i�z-c)rrr	rr r"�WNOHANGr!rrrrZget_preparation_data�itemsr0r1rZarbitrary_addressZbindrr#�chmodZlistenr2�filenoZget_executableZ_args_from_interpreter_flagsZspawnv_passfds)r�pidZstatus�cmd�data�listenerZaddress�alive_rZalive_wZfds_to_passZexe�argsrr;rr	isN





�
zForkServer.ensure_runningN)
�__name__�
__module__�__qualname__rrrrr
rr	rrrrr srcCs�|rdd|kr8|dk	r8dt��_zt�|�W5t��`X|D]&}zt|�Wq<tk
r`Yq<Xq<t��t	�
�\}}t	�|d�t	�|d�dd�}tj
|tjtji}	dd�|	��D�}
t�|�i}tjtj|d	���}t�����}
|��t_|
�|tj�|
�|tj�|
�|tj��z�d
d�|
��D�}|�r"�qB�q"||k�rjt	�|d�d
k�sftd��t�||k�r\t	�|d�zt	�dt	j �\}}Wnt!k
�r�Y�q\YnX|dk�rq\|�"|d�}|dk	�rJt	�#|��r�t	�$|�}n&t	�%|��std�&||���t	�'|�}zt(||�Wnt)k
�r<YnXt	�*|�nt+�,d|��q�||k�r�|�-�d��,}t.�/|t0d�}t1|�t0k�r�t2d�&t1|����|^}}}|�*�t	�3�}|dk�rNd}zpz<|�*�|
�*�||||g}|�5|�6��t7||||
�}Wn.t8k
�r:t9j:t9�;��t9j<�=�YnXW5t	�4|�XnNzt(||�Wnt)k
�rrYnX|||<t	�*|�|D]}t	�*|��q�W5QRXWn4t>k
�r�}z|j?t?j@k�r̂W5d}~XYnX�qW5QRXW5QRXdS)zRun forkserver.rNTFcWsdSrr)Z_unusedrrr�sigchld_handler�szmain.<locals>.sigchld_handlercSsi|]\}}|t�||��qSr)�signal)r'�sig�valrrrr<�s�zmain.<locals>.<dictcomp>)r@cSsg|]\}}|j�qSr)Zfileobj)r'�keyZeventsrrr�
<listcomp>�szmain.<locals>.<listcomp>r�zNot at EOF?i���rzChild {0:n} status is {1:n}z.forkserver: waitpid returned unexpected pid %dzToo many ({0:n}) fds to send)ArZcurrent_processZ_inheritingrZimport_main_path�
__import__�ImportErrorrZ_close_stdinr r2�set_blockingrK�SIGCHLD�SIGINT�SIG_IGNr>�
set_wakeup_fdr0r1�	selectorsZDefaultSelectorZgetsockname�_forkserverr�registerZ
EVENT_READZselect�read�AssertionError�
SystemExitr"r=�ChildProcessError�pop�WIFSIGNALED�WTERMSIG�	WIFEXITED�format�WEXITSTATUS�write_signed�BrokenPipeErrorr!�warnings�warnZacceptrZrecvfdsr.r-�RuntimeError�fork�_exit�extend�values�
_serve_one�	Exception�sys�
excepthook�exc_info�stderr�flush�OSError�errnoZECONNABORTED)Zlistener_fdrEZpreloadr6r7�modnameZsig_rZsig_wrJ�handlersZold_handlersZ	pid_to_fdrDZselectorZrfdsrA�stsr4�
returncode�sr3r5�code�
unused_fds�fd�errr�main�s�

��
�




��
�

��

�
r�c	Csht�d�|��D]\}}t�||�q|D]}t�|�q,|^t_tj_	t_
t�|�}t�
||�}|S)NrQ)rKrXr>r r!rZrrZ_resource_trackerZ_fdr�duprZ_main)	r5r3r~ryrLrMrZparent_sentinelr}rrrro1s
�
rocCsNd}tj}t|�|kr@t�||t|��}|s6td��||7}q
t�|�dS)NrPzunexpected EOFr)�
SIGNED_STRUCT�sizer-r r\�EOFErrorZunpack)rrCZlengthr|rrr�read_signedHs
r�cCs<t�|�}|r8t�||�}|dkr*td��||d�}q
dS)Nrzshould not get here)r�Zpackr �writerj)r�n�msg�nbytesrrrrfRs
rf)NN) rwr rYrKr0Zstructrqrrh�rr�contextrrrr�__all__r.ZStructr��objectrr�ror�rfrZr	r
rrrrrr�<module>s>�