AlkantarClanX12

Your IP : 18.117.70.64


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

o

6��f(%�@sddlmZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
gd�Zejdkp@e
ed�o@e
ed�o@e
ejd	�ZGd
d�dej�ZejZd8dd
�Zejdkr~egd�7ZddlZd9dd�dd�Zdd�Zdd�Zdd�ZGdd�de�Zn#egd�7ZddlZejdkZdd�Zdd �Zd!d�Zd"d�Zd#d$�Zd%d&�ZGd'd(�d(�Z ee!e �j"�e�d)d*�Z#ee!e$j%�e#�ee!e&j'�e#�d+d,�Z(d-d.�Z)eej*e(�ejdkr�d/d0�Z+d1d2�Z,eeje+�nd3d0�Z+d4d2�Z,eeje+�Gd5d6�d6ed7�Z-dS):�)�ABCMetaN�)�context)�send_handle�recv_handle�ForkingPickler�register�dump�win32ZCMSG_LEN�
SCM_RIGHTS�sendmsgcsJeZdZdZiZejZ�fdd�Ze	dd��Z
e	d	dd��Zej
Z
�ZS)
rz)Pickler subclass used by multiprocessing.cs*t�j|�|j��|_|j�|j�dS�N)�super�__init__�_copyreg_dispatch_table�copy�dispatch_table�update�_extra_reducers��self�args��	__class__��@/opt/alt/python310/lib64/python3.10/multiprocessing/reduction.pyr&szForkingPickler.__init__cCs||j|<dS)z&Register a reduce function for a type.N)r)�cls�type�reducerrrr+szForkingPickler.registerNcCs t��}|||��|�|��Sr
)�io�BytesIOr	�	getbuffer)r�obj�protocolZbufrrr�dumps0szForkingPickler.dumpsr
)�__name__�
__module__�__qualname__�__doc__r�copyregrrr�classmethodrr$�pickle�loads�
__classcell__rrrrr!s
rcCst||��|�dS)z3Replacement for pickle.dump() using ForkingPickler.N)rr	)r"�filer#rrrr	:sr	)�	DupHandle�	duplicate�steal_handleF)�source_processcCs6t��}|dur
|}|dur|}t�|||d|tj�S)z<Duplicate a handle.  (target_process is a handle not a pid!)Nr)�_winapi�GetCurrentProcess�DuplicateHandle�DUPLICATE_SAME_ACCESS)�handleZtarget_processZinheritabler2Zcurrent_processrrrr0Gs�r0c	CsJt�tjd|�}zt�||t��ddtjtjB�Wt�|�St�|�w)z5Steal a handle from process identified by source_pid.Fr)r3�OpenProcess�PROCESS_DUP_HANDLEr5r4r6�DUPLICATE_CLOSE_SOURCE�CloseHandle)Z
source_pidr7Zsource_process_handlerrrr1Ss�

�r1cCst|tj|�}|�|�dS�z&Send a handle over a local connection.N)r/r3r6�send)�connr7�destination_pidZdhrrrr_srcCs|����S)�)Receive a handle over a local connection.)�recv�detach)r>rrrrdsrc@s"eZdZdZddd�Zdd�ZdS)r/zPicklable wrapper for a handle.Nc	Csf|durt��}t�tjd|�}zt�t��|||dd�|_Wt�|�nt�|�w||_	||_
dS)NFr)�os�getpidr3r8r9r5r4�_handler;�_access�_pid)rr7�access�pid�procrrrrjs
�
zDupHandle.__init__c	Cs^|jt��kr
|jSt�tjd|j�}zt�||jt��|j	dtj
�Wt�|�St�|�w)z1Get the handle.  This should only be called once.F)rGrCrDrEr3r8r9r5r4rFr:r;)rrJrrrrBys
�
�zDupHandle.detachr
)r%r&r'r(rrBrrrrr/hs
r/)�DupFd�sendfds�recvfds�darwincCsZt�d|�}tt|�dg�}|�|gtjtj|fg�tr)|�d�dkr+t	d��dSdS)z,Send an array of fds over an AF_UNIX socket.�i�r�Az%did not receive acknowledgement of fdN)
�array�bytes�lenr�socket�
SOL_SOCKETr�ACKNOWLEDGErA�RuntimeError)�sockZfds�msgrrrrL�s�rLc	Cst�d�}|j|}|�dt�|��\}}}}|s|st�z[tr%|�d�t|�dkr3t	dt|���|d\}}	}
|tj
kro|	tjkrtt|
�|jdkrOt�|�
|
�t|�d|dkrjtd�t|�|d���t|�WSWt	d��Wt	d��ttfy�Yt	d��w)	z/Receive an array of fds over an AF_UNIX socket.rOrrQzreceived %d items of ancdatarrPz Len is {0:n} but msg[0] is {1!r}zInvalid data received)rR�itemsizeZrecvmsgrUZ
CMSG_SPACE�EOFErrorrWr=rTrXrVr�
ValueErrorZ	frombytes�AssertionError�format�list�
IndexError)rY�size�aZ
bytes_sizerZZancdata�flagsZaddrZ
cmsg_levelZ	cmsg_typeZ	cmsg_datarrrrM�sB


�


��
����rMcCsHt�|��tjtj��}t||g�Wd�dS1swYdSr<)rU�fromfd�fileno�AF_UNIX�SOCK_STREAMrL)r>r7r?�srrrr�s"�cCsHt�|��tjtj��}t|d�dWd�S1swYdS)r@rrN)rUrerfrgrhrM)r>rirrrr�s$�cCsBt��}|dur|�|�|��Strddlm}|�|�Std��)zReturn a wrapper for an fd.Nr)�resource_sharerz&SCM_RIGHTS appears not to be available)rZget_spawning_popenrKZduplicate_for_child�HAVE_SEND_HANDLE�rjr])�fdZ	popen_objrjrrrrK�s
rKcCs.|jdurt|j|jjffSt|j|jjffSr
)�__self__�getattrr�__func__r%��mrrr�_reduce_method�s
rsc@seZdZdd�ZdS)�_CcCsdSr
r)rrrr�f�sz_C.fN)r%r&r'rurrrrrt�srtcCst|j|jffSr
)ro�__objclass__r%rqrrr�_reduce_method_descriptor�srwcCst|j|j|jp	iffSr
)�_rebuild_partial�funcr�keywords)�prrr�_reduce_partial��r|cCstj|g|�Ri|��Sr
)�	functools�partial)ryrrzrrrrx�r}rxcCsddlm}t||�ffS)Nr)�	DupSocket)rjr��_rebuild_socket)rir�rrr�_reduce_socket�sr�cCs|��Sr
)rB)Zdsrrrr��sr�cCs"t|���}t||j|j|jffSr
)rKrfr��familyr�proto)ri�dfrrrr��scCs|��}tj||||d�S)N)rf)rBrU)r�r�rr�rmrrrr��sc@sdeZdZdZeZeZeZeZeZe	j
dkreZeZe
Z
neZeZeZeZeZeZeZeZdd�ZdS)�AbstractReducerz�Abstract base class for use in implementing a Reduction class
    suitable for use in replacing the standard reduction mechanism
    used in multiprocessing.r
cGsNttt�j�t�tttj�t�tttj	�t�tt
jt�tt
j
t�dSr
)rrrtrursr`�appendrw�int�__add__r~rr|rUr�rrrrrs
zAbstractReducer.__init__N)r%r&r'r(rrr	rr�sys�platformr1r0r/rLrMrKrsrwrxr�r�rrrrrr��s(
r�)�	metaclassr
)NF).�abcrr)r~rrCr+rUr�rlr�__all__r��hasattrrkZPicklerrrr	r3r0r1rr�objectr/rRrWrLrMrKrsrtrrurwr`r�r�r�r|rxrr�r�r�rrrr�<module>sl	

�
�	

�#