AlkantarClanX12

Your IP : 3.144.235.141


Current Path : /opt/alt/python39/lib64/python3.9/multiprocessing/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/multiprocessing/__pycache__/forkserver.cpython-39.pyc

a

R�fn/�@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�	threadingZLock�_lock�_preload_modules��self�r�?/opt/alt/python39/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_UNIXZconnectrr �piperrZgetfdrZsendfdsr!)r�fdsZclientZparent_r�child_w�child_rZparent_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>r2i�z-c)rrr	rr r"�WNOHANGr!rrrrZget_preparation_data�itemsr1r2rZarbitrary_addressZbindrr#�chmodZlistenr3�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|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�valrrrr=�s�zmain.<locals>.<dictcomp>)rAcSsg|]\}}|j�qSr)Zfileobj)r'�keyZeventsrrr�
<listcomp>�r*zmain.<locals>.<listcomp>rr*zNot at EOF?i���rz.forkserver: waitpid returned unexpected pid %dzToo many ({0:n}) fds to send)=rZcurrent_processZ_inheritingrZimport_main_path�
__import__�ImportErrorrZ_close_stdinr r3�set_blockingrL�SIGCHLD�SIGINT�SIG_IGNr?�
set_wakeup_fdr1r2�	selectorsZDefaultSelectorZgetsockname�_forkserverr�registerZ
EVENT_READZselect�read�
SystemExitr"r>�ChildProcessError�pop�waitstatus_to_exitcode�write_signed�BrokenPipeErrorr!�warnings�warnZacceptrZrecvfdsr/r.�RuntimeError�format�fork�extend�values�
_serve_one�	Exception�sys�
excepthook�exc_info�stderr�flush�_exit�OSError�errnoZECONNABORTED)Zlistener_fdrFZpreloadr7r8�modnameZsig_rZsig_wrK�handlersZold_handlersZ	pid_to_fdrEZselectorZrfdsrB�stsr5�
returncode�sr4r6�code�
unused_fds�fd�errr�main�s�
��
�





�

��

�
2r}c	Csht�d�|��D]\}}t�||�q|D]}t�|�q,|^t_tj_	t_
t�|�}t�
||�}|S)NrQ)rLrXr?r r!rZrrZ_resource_trackerZ_fdr�duprZ_main)	r6r4rzrurMrNr{Zparent_sentinelryrrrrj+s
�
rjcCsNd}tj}t|�|kr@t�||t|��}|s6td��||7}q
t�|�dS)Nr*zunexpected EOFr)�
SIGNED_STRUCT�sizer.r r\�EOFErrorZunpack)r{rDZlengthrxrrr�read_signedBs
r�cCs<t�|�}|r8t�||�}|dkr*td��||d�}q
dS)Nrzshould not get here)rZpackr �writere)r{�n�msg�nbytesrrrraLs
ra)NN) rsr rYrLr1Zstructrlrrc�rr�contextrrrr�__all__r/ZStructr�objectrr}rjr�rarZr	r
rrrrrr�<module>s: