AlkantarClanX12

Your IP : 18.223.206.84


Current Path : /opt/alt/python37/lib64/python3.7/multiprocessing/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/multiprocessing/__pycache__/reduction.cpython-37.pyc

B

� f�$�@sddlmZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddddd	gZejd
kp�e
ed�o�e
ed�o�e
ejd
�ZGdd�dej�ZejZd5dd	�Zejd
k�redddg7ZddlZd6dd�Zdd�Zdd�Zdd�ZGdd�de�ZnHedddg7ZddlZejdkZdd�Zdd�Zdd�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d
k�r�d,d-�Z+d.d/�Z,eeje+�nd0d-�Z+d1d/�Z,eeje+�Gd2d3�d3ed4�Z-dS)7�)�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/python37/lib64/python3.7/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��}|||��|�|��S)N)�io�BytesIOr	�	getbuffer)r�obj�protocolZbufrrr�dumps0szForkingPickler.dumps)N)�__name__�
__module__�__qualname__�__doc__r�copyregrrr�classmethodrr!�pickle�loads�
__classcell__rr)rrr!scCst||��|�dS)z3Replacement for pickle.dump() using ForkingPickler.N)rr	)r�filer rrrr	:s�	DupHandle�	duplicate�steal_handleFcCs*|dkrt��}t�t��||d|tj�S)z<Duplicate a handle.  (target_process is a handle not a pid!)Nr)�_winapi�GetCurrentProcess�DuplicateHandle�DUPLICATE_SAME_ACCESS)�handleZtarget_processZinheritablerrrr-Gs

c	CsBt�tjd|�}z t�||t��ddtjtjB�St�|�XdS)z5Steal a handle from process identified by source_pid.FrN)r/�OpenProcess�PROCESS_DUP_HANDLEr1r0r2�DUPLICATE_CLOSE_SOURCE�CloseHandle)Z
source_pidr3Zsource_process_handlerrrr.Os
cCst|tj|�}|�|�dS)z&Send a handle over a local connection.N)r,r/r2�send)�connr3�destination_pidZdhrrrr[scCs|����S)z)Receive a handle over a local connection.)�recv�detach)r9rrrr`sc@s"eZdZdZddd�Zdd�ZdS)r,zPicklable wrapper for a handle.Nc	Cs\|dkrt��}t�tjd|�}zt�t��|||dd�|_Wdt�|�X||_	||_
dS)NFr)�os�getpidr/r4r5r1r0�_handler7�_access�_pid)rr3�access�pid�procrrrrfszDupHandle.__init__c	CsV|jt��kr|jSt�tjd|j�}zt�||jt��|j	dtj
�St�|�XdS)z1Get the handle.  This should only be called once.FN)rAr=r>r?r/r4r5r1r0r@r6r7)rrDrrrr<us
zDupHandle.detach)N)r"r#r$r%rr<rrrrr,ds
�DupFd�sendfds�recvfds�darwincCsVt�d|�}tt|�dg�}|�|gtjtj|fg�trR|�d�dkrRt	d��dS)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�ACKNOWLEDGEr;�RuntimeError)�sockZfds�msgrrrrF�s
c	Cst�d�}|j|}|�dt�|��\}}}}|s:|s:t�y�trJ|�d�t|�dkrft	dt|���|d\}}	}
|tj
kr�|	tjkr�t|
�|jdkr�t�|�
|
�t|�d|dkr�td�t|�|d���t|�SWnttfk
r�YnXt	d��d	S)
z/Receive an array of fds over an AF_UNIX socket.rIrrKzreceived %d items of ancdatarrJz Len is {0:n} but msg[0] is {1!r}zInvalid data receivedN)rL�itemsizeZrecvmsgrOZ
CMSG_SPACE�EOFErrorrQr8rNrRrPr�
ValueErrorZ	frombytes�AssertionError�format�list�
IndexError)rS�size�aZ
bytes_sizerTZancdata�flagsZaddrZ
cmsg_levelZ	cmsg_typeZ	cmsg_datarrrrG�s2





c	Cs2t�|��tjtj��}t||g�WdQRXdS)z&Send a handle over a local connection.N)rO�fromfd�fileno�AF_UNIX�SOCK_STREAMrF)r9r3r:�srrrr�sc	Cs0t�|��tjtj��}t|d�dSQRXdS)z)Receive a handle over a local connection.rrN)rOr_r`rarbrG)r9rcrrrr�scCsFt��}|dk	r |�|�|��Str:ddlm}|�|�Std��dS)zReturn a wrapper for an fd.Nr)�resource_sharerz&SCM_RIGHTS appears not to be available)rZget_spawning_popenrEZduplicate_for_child�HAVE_SEND_HANDLE�rdrW)�fdZ	popen_objrdrrrrE�s
cCs2|jdkrt|j|jjffSt|j|jjffSdS)N)�__self__�getattrr�__func__r")�mrrr�_reduce_method�s
rlc@seZdZdd�ZdS)�_CcCsdS)Nr)rrrr�f�sz_C.fN)r"r#r$rnrrrrrm�srmcCst|j|jffS)N)ri�__objclass__r")rkrrr�_reduce_method_descriptor�srpcCst|j|j|jpiffS)N)�_rebuild_partial�funcr�keywords)�prrr�_reduce_partial�srucCstj|f|�|�S)N)�	functools�partial)rrrrsrrrrq�srqcCsddlm}t||�ffS)Nr)�	DupSocket)rdrx�_rebuild_socket)rcrxrrr�_reduce_socket�srzcCs|��S)N)r<)Zdsrrrry�srycCs"t|���}t||j|j|jffS)N)rEr`ry�familyr�proto)rc�dfrrrrz�scCs|��}tj||||d�S)N)r`)r<rO)r}r{rr|rgrrrry�sc@sdeZdZdZeZeZeZeZeZe	j
dkr8eZeZe
Z
neZeZeZeZeZeZeZeZdd�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�dS)N)rrrmrnrlrZ�appendrp�int�__add__rvrwrurOrz)rrrrrrs
zAbstractReducer.__init__N)r"r#r$r%rrr	rr�sys�platformr.r-r,rFrGrErlrprqrzryrrrrrr~�s&
r~)�	metaclass)N)NF).�abcrr&rvrr=r(rOr�rfr�__all__r��hasattrreZPicklerrrr	r/r-r.rr�objectr,rLrQrFrGrErlrmrrnrprZrr�r�rurqrwrzryr~rrrr�<module>
sb




#