Your IP : 13.59.36.36


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.opt-2.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)Ncss�|]	}t|�tuVqdSr)�type�str)�.0�modrrr�	<genexpr>@s�z4ForkServer.set_forkserver_preload.<locals>.<genexpr>z&module_names must be a list of strings)�allr�	TypeError)rZ
modules_namesrrrr>s
z!ForkServer.set_forkserver_preloadcCs	|jSr)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�|�w1srwYdS)N�ztoo many fds)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��|jdur2t�|jtj�\}}|s#	Wd�dSt�|j�d|_	d|_d|_d}|j
rLddh�t�d�}�fdd�|�
�D�}ni}t�tj��s}t�d�}|�|�t�|�sjt�|d�|��t��\}}z<z+|��|g}	||��||j
|f;}t��}
|
gt��}|d	|g7}t�|
||	�}Wn	t�|��Wt�|�nt�|�w||_	||_||_Wd�n1s�wYWd�dSWd�dS1s�wYdS)
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	is\
�	



�
���"�zForkServer.ensure_runningN)
�__name__�
__module__�__qualname__rrrrr
rr	rrrrr srcCs�	|r5d|vr!|dur!dt��_zt�|�Wt��`nt��`w|D]}zt|�Wq#ty4Yq#wt��t	�
�\}}t	�|d�t	�|d�dd�}tj
|tjtji}	dd�|	��D�}
t�|�i}tjtj|d���k}t����T}
|��t_|
�|tj�|
�|tj�|
�|tj�	�z	d	d
�|
��D�}|r�nq�||vr�t�||vr�t	�|d�	zt	�dt	j�\}}Wn	t y�Yn4w|d
kr�n.|�!|d�}|dur�t	�"|�}zt#||�Wn	t$y�Ynwt	�%|�nt&�'d|�q�||v�r�|�(�d
��}t)�*|t+d�}t,|�t+k�r t-d�.t,|����|^}}}|�%�t	�/�}|d
k�rwd}z<z|�%�|
�%�||||g}|�0|�1��t2||||
�}Wnt3�yit4j5t4�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)NrTFcWsdSrr)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>i���rz.forkserver: waitpid returned unexpected pid %drzToo 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�
SystemExit�readr"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)NrP)rKrWr>r r!rYrrZ_resource_trackerZ_fdr�duprZ_main)	r5r3ryrtrLrMrzZparent_sentinelrxrrrri+s
�
ricCsXd}tj}t|�|kr%t�||t|��}|std��||7}t|�|kst�|�dS)N�zunexpected EOFr)�
SIGNED_STRUCT�sizer-r r\�EOFErrorZunpack)rzrCZlengthrwrrr�read_signedBs�r�cCsBt�|�}|rt�||�}|dkrtd��||d�}|sdSdS)Nrzshould not get here)rZpackr �writerd)rz�n�msg�nbytesrrrr`Ls
�r`)NN) rrr rXrKr0Zstructrkrrb�rr�contextrrrr�__all__r.ZStructr�objectrr|rir�r`rYr	r
rrrrrr�<module>s<





?>