Mini Shell

Direktori : /lib64/python3.9/multiprocessing/__pycache__/
Upload File :
Current File : //lib64/python3.9/multiprocessing/__pycache__/forkserver.cpython-39.pyc

a

�DOgn/�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddl	mZddlm
Z
ddl	mZddl	mZddl	mZgd	�Zd
Ze�d�ZGdd
�d
e�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�	threading�Lock�_lock�_preload_modules��self�r�2/usr/lib64/python3.9/multiprocessing/forkserver.py�__init__"s
zForkServer.__init__cCs2|j�|��Wd�n1s$0YdS�N)r�_stop_unlockedrrrr�_stop*szForkServer._stopcCsV|jdurdSt�|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|�tuVqdSr)�type�str)�.0�modrrr�	<genexpr>@�z4ForkServer.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}zvz:t
�||�||fWWt�|�t�|�Wd�St�|�t�|��Yn0Wt�|�t�|�nt�|�t�|�0Wd�n1�s0YdS)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_UNIX�connectrr!�piperrZgetfdr�sendfdsr")r�fds�client�parent_r�child_w�child_r�parent_wZallfdsrrrrLs2�


�



�
z!ForkServer.connect_to_new_processcs�|j���t��|jdurbt�|jtj�\}}|sDWd�dSt�|j�d|_	d|_d|_d}|j
r�ddh�t�d�}�fdd�|�
�D�}ni}t�tj���}t�d�}|�|�t�|�s�t�|d	�|��t��\}}z~zV|��|g}	||��||j
|f;}t��}
|
gt��}|d
|g7}t�|
||	�}Wnt�|��Yn0Wt�|�nt�|�0||_	||_||_Wd�n1�s�0YWd�n1�s�0YdS)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|]\}}|�vr||�qSrr)r(�x�y�Zdesired_keysrr�
<dictcomp>�r+z-ForkServer.ensure_running.<locals>.<dictcomp>r3i�z-c)rrr	rr!r#�WNOHANGr"rrrrZget_preparation_data�itemsr2r3r�arbitrary_address�bindrr$�chmod�listenr5�filenoZget_executable�_args_from_interpreter_flags�spawnv_passfds)r�pid�status�cmd�data�listener�address�alive_rZalive_wZfds_to_passZexe�argsrrBrr	isN





�

zForkServer.ensure_runningN)
�__name__�
__module__�__qualname__rr rrr
rr	rrrrr srcCs|rjd|vr@|dur@dt��_zt�|�Wt��`n
t��`0|D]$}zt|�WqDtyfYqD0qDt��t	�
�\}}t	�|d�t	�|d�dd�}tj
|tjtji}	dd�|	��D�}
t�|�i}tjtj|d	���}t�����}
|��t_|
�|tj�|
�|tj�|
�|tj��zjd
d�|
��D�}|�r(�qH�q(||v�rpt	�|d�d
k�slJd��t�||v�r(t	�|d�zt	�dt	j�\}}Wnt �y�Y�q(Yn0|dk�rƐq(|�!|d�}|du�rt	�"|�}zt#||�Wnt$�yYn0t	�%|�nt&�'d|��q�||v�r�|�(�d��<}t)�*|t+d�}t,|�t+k�rrt-d�.t,|����|^}}}|�%�t	�/�}|dk�r"d}zxz<|�%�|
�%�||||g}|�0|�1��t2||||
�}Wn,t3�yt4j5t4�6��t4j7�8�Yn0Wt	�9|�nt	�9|�0nLzt#||�Wnt$�yDYn0|||<t	�%|�|D]}t	�%|��q\Wd�n1�s�0YWn6t:�y�}z|j;t;j<k�r��WYd}~n
d}~00�q$Wd�n1�s�0YWd�n1�s0YdS)zRun forkserver.rNTFcWsdSrr)Z_unusedrrr�sigchld_handler�szmain.<locals>.sigchld_handlercSsi|]\}}|t�||��qSr)�signal)r(�sig�valrrrrC�s�zmain.<locals>.<dictcomp>)rJcSsg|]\}}|j�qSr)�fileobj)r(�key�eventsrrr�
<listcomp>�r+zmain.<locals>.<listcomp>rr+zNot at EOF?i���rz.forkserver: waitpid returned unexpected pid %dzToo many ({0:n}) fds to send)=r�current_processZ_inheritingrZimport_main_path�
__import__�ImportErrorr�_close_stdinr!r5�set_blockingrY�SIGCHLD�SIGINT�SIG_IGNrE�
set_wakeup_fdr2r3�	selectors�DefaultSelector�getsockname�_forkserverr�register�
EVENT_READ�select�read�
SystemExitr#rD�ChildProcessError�pop�waitstatus_to_exitcode�write_signed�BrokenPipeErrorr"�warnings�warn�acceptr�recvfdsr0r/�RuntimeError�format�fork�extend�values�
_serve_one�	Exception�sys�
excepthook�exc_info�stderr�flush�_exit�OSError�errnoZECONNABORTED)Zlistener_fdrSZpreloadr=r>�modnameZsig_rZsig_wrX�handlersZold_handlersZ	pid_to_fdrQ�selectorZrfdsrM�stsr:�
returncode�sr7r;�code�
unused_fds�fd�errr�main�s�
��
�





�

��

�
2r�c	Csht�d�|��D]\}}t�||�q|D]}t�|�q,|^t_tj_	t_
t�|�}t�
||�}|S)Nr`)rYrirEr!r"rmrr�_resource_trackerZ_fdr�duprZ_main)	r;r7r�r�rZr[r��parent_sentinelr�rrrr�+s
�
r�cCsNd}tj}t|�|kr@t�||t|��}|s6td��||7}q
t�|�dS)Nr+zunexpected EOFr)�
SIGNED_STRUCT�sizer/r!rq�EOFError�unpack)r�rP�lengthr�rrr�read_signedBs
r�cCs<t�|�}|r8t�||�}|dkr*td��||d�}q
dS)Nrzshould not get here)r��packr!�writer|)r��n�msg�nbytesrrrrvLs
rv)NN) r�r!rjrYr2�structr�rrx�rr�contextrrrr�__all__r0�Structr��objectrr�r�r�rvrmr	r
rrrrrr�<module>s:




Zerion Mini Shell 1.0