AlkantarClanX12

Your IP : 3.145.8.2


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

a

R�f�@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��D/opt/alt/python39/lib64/python3.9/multiprocessing/resource_sharer.py�sends
z DupSocket.__init__.<locals>.send)�dup�_resource_sharer�register�close�_id)�selfZsockrr
rr�__init__szDupSocket.__init__cCsBt�|j��"}|��}t�|�Wd�S1s40YdS)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__cCs:t�|j��}t�|�Wd�S1s,0YdS)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|_t��|_d|_d|_d|_t�	|t
j�dS)Nr)�_key�_cache�	threadingZLock�_lock�	_listener�_address�_threadrZregister_after_forkr#�
_afterfork)rr
r
rr?s
z_ResourceSharer.__init__cCsf|j�L|jdur|��|jd7_||f|j|j<|j|jfWd�S1sX0YdS)z+Register resource, returning an identifier.Nr)r'r)�_startr$r%)rrrr
r
rrHs
z_ResourceSharer.registercCs<ddlm}|\}}||t��jd�}|�|t��f�|S)z<Return connection from which to receive identified resource.r��Client��authkey)�
connectionr.r�current_processr0rr!�getpid)Zidentr.�address�key�cr
r
rrQs
z_ResourceSharer.get_connectionNcCs�ddlm}|j��|jdur�||jt��jd�}|�d�|��|j	�
|�|j	��rdt�
d�|j��d|_	d|_d|_|j��D]\}\}}|�q�|j��Wd�n1s�0YdS)z:Stop the background thread and clear registered resources.rr-Nr/z._ResourceSharer thread did not stop when asked)r1r.r'r)rr2r0rrr*�joinZis_aliverZsub_warningr(r%�items�clear)rZtimeoutr.r6r5rrr
r
rrZs$
�



z_ResourceSharer.stopcCs\|j��D]\}\}}|�q
|j��|j��|jdurF|j��d|_d|_d|_dSr)	r%r8r9r'�_at_fork_reinitr(rr)r*)rr5rrr
r
rr+os



z_ResourceSharer._afterforkcCsjddlm}|jdusJd��t�d�|t��jd�|_|jj|_	t
j|jd�}d|_
|��||_dS)Nr)�ListenerzAlready have Listenerz0starting listener and thread for sending handlesr/)�targetT)r1r;r(r�debugrr2r0r4r)r&ZThread�_serveZdaemon�startr*)rr;�tr
r
rr,zs

z_ResourceSharer._startcCs�ttd�rt�tjt���z�|j���f}|��}|durJWd�Wq�|\}}|j�	|�\}}z|||�W|�n|�0Wd�n1s�0YWqt
��s�tj
t���Yq0qdS)N�pthread_sigmask)�hasattr�signalrA�	SIG_BLOCK�
valid_signalsr(ZacceptZrecvr%�poprZ
is_exiting�sys�
excepthook�exc_info)rr
�msgr5Zdestination_pidrrr
r
rr>�s
2z_ResourceSharer._serve)N)rrrrrr�staticmethodrrr+r,r>r
r
r
rr#=s		

r#)r!rCrrGr&�r�contextrr�__all__�platform�objectrrr#rrr
r
r
r�<module>s 


\