AlkantarClanX12

Your IP : 18.188.132.71


Current Path : /opt/alt/python310/lib64/python3.10/multiprocessing/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/multiprocessing/__pycache__/forkserver.cpython-310.pyc

o

6��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�A/opt/alt/python310/lib64/python3.10/multiprocessing/forkserver.py�__init__"s
zForkServer.__init__cCs4|j�
|��Wd�dS1swYdS�N)r�_stop_unlockedrrrr�_stop*s
"�zForkServer._stopcCsV|jdurdSt�|j�d|_t�|jd�d|_t�|j�s&t�|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>@s�z4ForkServer.set_forkserver_preload.<locals>.<genexpr>z&module_names must be a list of stringsN)�allr�	TypeError)rZ
modules_namesrrrr>s
z!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|�dtkrtd��t�tj��X}|�|j�t�	�\}}t�	�\}}|||j
t��g}||7}z,zt
�||�||fWWt�|�t�|�Wd�St�|�t�|��t�|�t�|�w1sqwYdS)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_wZallfdsrrrrLs0�


�



�z!ForkServer.connect_to_new_processcs�|j��t��|jdur1t�|jtj�\}}|s"	Wd�dSt�|j�d|_	d|_d|_d}|j
rKddh�t�d�}�fdd�|�
�D�}ni}t�tj��s}t�d�}|�|�t�|�sit�|d	�|��t��\}}z<z+|��|g}	||��||j
|f;}t��}
|
gt��}|d
|g7}t�|
||	�}Wn	t�|��Wt�|�nt�|�w||_	||_||_Wd�n1s�wYWd�dSWd�dS1s�wYdS)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>�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	isZ
�	



�
���"�zForkServer.ensure_runningN)
�__name__�
__module__�__qualname__rrrrr
rr	rrrrr srcCs�|r4d|vr |dur dt��_zt�|�Wt��`nt��`w|D]}zt|�Wq"ty3Yq"wt��t	�
�\}}t	�|d�t	�|d�dd�}tj
|tjtji}	dd�|	��D�}
t�|�i}tjtj|d	���y}t����b}
|��t_|
�|tj�|
�|tj�|
�|tj�	�z(	d
d�|
��D�}|r�nq�||vr�t	�|d�d
ks�Jd��t�||v�r	t	�|d�	zt	�dt	j�\}}Wn	t y�Yn5w|dkr�n/|�!|d�}|du�rt	�"|�}zt#||�Wn	t$y�Ynwt	�%|�nt&�'d|�q�||v�r�|�(�d��}t)�*|t+d�}t,|�t+k�r-t-d�.t,|����|^}}}|�%�t	�/�}|dk�r�d}z<z|�%�|
�%�||||g}|�0|�1��t2||||
�}Wnt3�yvt4j5t4�6��t4j7�8�YnwWt	�9|�n,t	�9|�wzt#||�Wn
t$�y�Ynw|||<t	�%|�|D]}t	�%|��q�Wd�n	1�s�wYWnt:�y�}z|j;t;j<k�r̂WYd}~nd}~wwq�1�s�wYWd�dS1�s�wYdS)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���rz.forkserver: waitpid returned unexpected pid %dzToo many ({0:n}) fds to send)=rZcurrent_processZ_inheritingrZimport_main_path�
__import__�ImportErrorrZ_close_stdinr r2�set_blockingrK�SIGCHLD�SIGINT�SIG_IGNr>�
set_wakeup_fdr0r1�	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_fdrEZpreloadr6r7�modnameZsig_rZsig_wrJ�handlersZold_handlersZ	pid_to_fdrDZselectorZrfdsrA�stsr4�
returncode�sr3r5�code�
unused_fds�fd�errr�main�s�
���
�
�
�

���
��

����
���&����8�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)	r5r3rzrurLrMr{Zparent_sentinelryrrrrj+s
�
rjcCsXd}tj}t|�|kr%t�||t|��}|std��||7}t|�|kst�|�dS)NrPzunexpected EOFr)�
SIGNED_STRUCT�sizer-r r\�EOFErrorZunpack)r{rCZlengthrxrrr�read_signedBs�r�cCsBt�|�}|rt�||�}|dkrtd��||d�}|sdSdS)Nrzshould not get here)rZpackr �writere)r{�n�msg�nbytesrrrraLs
�ra)NN) rsr rYrKr0Zstructrlrrc�rr�contextrrrr�__all__r.ZStructr�objectrr}rjr�rarZr	r
rrrrrr�<module>s<