Your IP : 18.218.50.170


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

U

e5d��@s�ddlZddlZddlZddlZddlZddlmZddlmZddlm	Z	dgZ
ejdkrxe
dg7Z
Gd	d�de�Z
ne
d
g7Z
Gdd
�d
e�ZGdd
�d
e�Ze�ZejZdS)�N�)�process)�	reduction)�util�stopZwin32�	DupSocketc@s eZdZdZdd�Zdd�ZdS)rzPicklable wrapper for a socket.cs(|����fdd�}t�|�j�|_dS)Ncs��|�}|�|�dS�N)�shareZ
send_bytes)�conn�pidr	�Znew_sock��7/usr/lib64/python3.8/multiprocessing/resource_sharer.py�sends
z DupSocket.__init__.<locals>.send)�dup�_resource_sharer�register�close�_id)�selfZsockrr
rr�__init__szDupSocket.__init__c
Cs6t�|j�� }|��}t�|�W5QR�SQRXdS)z1Get the socket.  This should only be called once.N)r�get_connectionrZ
recv_bytes�socketZ	fromshare)rr
r	r
r
r�detach$szDupSocket.detachN��__name__�
__module__�__qualname__�__doc__rrr
r
r
rrs�DupFdc@s eZdZdZdd�Zdd�ZdS)rz-Wrapper for fd which can be used at any time.cs4t�|���fdd�}�fdd�}t�||�|_dS)Ncst�|�|�dSr)rZsend_handle)r
r�Znew_fdr
rr1szDupFd.__init__.<locals>.sendcst���dSr)�osrr
r r
rr3szDupFd.__init__.<locals>.close)r!rrrr)r�fdrrr
r rr/s
zDupFd.__init__c
Cs.t�|j��}t�|�W5QR�SQRXdS)z-Get the fd.  This should only be called once.N)rrrrZrecv_handle)rr
r
r
rr7szDupFd.detachNrr
r
r
rr-sc@sNeZdZdZdd�Zdd�Zedd��Zdd	d
�Zdd�Z	d
d�Z
dd�ZdS)�_ResourceSharerz.Manager for resources using background thread.cCs@d|_i|_g|_t��|_d|_d|_d|_t	�
|tj�dS)Nr)
�_key�_cache�
_old_locks�	threading�Lock�_lock�	_listener�_address�_threadrZregister_after_forkr#�
_afterfork)rr
r
rr?s
z_ResourceSharer.__init__c
CsZ|j�J|jdkr|��|jd7_||f|j|j<|j|jfW5QR�SQRXdS)z+Register resource, returning an identifier.Nr)r)r+�_startr$r%)rrrr
r
rrIs
z_ResourceSharer.registercCs<ddlm}|\}}||t��jd�}|�|t��f�|S)z<Return connection from which to receive identified resource.r��Client��authkey)�
connectionr0r�current_processr2rr!�getpid)Zidentr0�address�key�cr
r
rrRs
z_ResourceSharer.get_connectionNc	Cs�ddlm}|j��|jdk	r�||jt��jd�}|�d�|��|j	�
|�|j	��rdt�
d�|j��d|_	d|_d|_|j��D]\}\}}|�q�|j��W5QRXdS)z:Stop the background thread and clear registered resources.rr/Nr1z._ResourceSharer thread did not stop when asked)r3r0r)r+rr4r2rrr,�joinZis_aliverZsub_warningr*r%�items�clear)rZtimeoutr0r8r7rrr
r
rr[s$
�



z_ResourceSharer.stopcCsj|j��D]\}\}}|�q
|j��|j�|j�t��|_|jdk	rT|j�	�d|_d|_
d|_dSr)r%r:r;r&�appendr)r'r(r*rr+r,)rr7rrr
r
rr-ps



z_ResourceSharer._afterforkcCsjddlm}|jdkstd��t�d�|t��jd�|_|jj	|_
tj|j
d�}d|_|��||_dS)Nr)�ListenerzAlready have Listenerz0starting listener and thread for sending handlesr1)�targetT)r3r=r*�AssertionErrorr�debugrr4r2r6r+r'ZThread�_serveZdaemon�startr,)rr=�tr
r
rr.~s

z_ResourceSharer._startc	Cs�ttd�rt�tjt���zh|j���T}|��}|dkrHW5QR�Wq�|\}}|j�	|�\}}z|||�W5|�XW5QRXWqt
��s�tj
t���YqXqdS)N�pthread_sigmask)�hasattr�signalrD�	SIG_BLOCK�
valid_signalsr*ZacceptZrecvr%�poprZ
is_exiting�sys�
excepthook�exc_info)rr
�msgr7Zdestination_pidrrr
r
rrA�s
z_ResourceSharer._serve)N)rrrrrr�staticmethodrrr-r.rAr
r
r
rr#=s
	

r#)r!rFrrJr'�r�contextrr�__all__�platform�objectrrr#rrr
r
r
r�<module>s 


`

?>