Your IP : 13.59.69.109


Current Path : /opt/alt/python35/lib64/python3.5/multiprocessing/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/multiprocessing/__pycache__/reduction.cpython-35.pyc



��Yf��@s�ddlZddlZddlZddlZddlZddlZddlZddlmZdddddgZ	ej
d	kp�eed
�o�eed�o�eejd�ZGd
d�dej
�ZejZddd�Zej
d	krfe	dddg7Z	ddlZdddd�Zdd�Zdd�Zdd�ZGdd�de�Znje	dddg7Z	ddlZej
dkZdd�Zdd�Zdd�Zdd�Zd d�Zd!d"�ZGd#d$�d$�Zeee�j �e�d%d&�Z!eee"j#�e!�eee$j%�e!�d'd(�Z&d)d*�Z'eej(e&�ej
d	kr�d+d,�Z)d-d.�Z*eeje)�n(d/d,�Z)d0d.�Z*eeje)�dS)1�N�)�context�send_handle�recv_handle�ForkingPickler�register�dump�win32�CMSG_LEN�
SCM_RIGHTS�sendmsgcsgeZdZdZiZejZ�fdd�Ze	dd��Z
e	ddd��Zej
Z
�S)	rz)Pickler subclass used by multiprocessing.cs9t�j|�|jj�|_|jj|j�dS)N)�super�__init__�_copyreg_dispatch_table�copy�dispatch_table�update�_extra_reducers)�self�args)�	__class__��>/opt/alt/python35/lib64/python3.5/multiprocessing/reduction.pyr%szForkingPickler.__init__cCs||j|<dS)z&Register a reduce function for a type.N)r)�cls�type�reducerrrr*szForkingPickler.registerNcCs,tj�}|||�j|�|j�S)N)�io�BytesIOr�	getbuffer)r�obj�protocolZbufrrr�dumps/szForkingPickler.dumps)�__name__�
__module__�__qualname__�__doc__r�copyregrrr�classmethodrr!�pickle�loadsrr)rrr s	cCst||�j|�dS)z3Replacement for pickle.dump() using ForkingPickler.N)rr)r�filer rrrr9s�	DupHandle�	duplicate�steal_handleFcCs=|dkrtj�}tjtj�||d|tj�S)z<Duplicate a handle.  (target_process is a handle not a pid!)Nr)�_winapi�GetCurrentProcess�DuplicateHandle�DUPLICATE_SAME_ACCESS)�handleZtarget_processZinheritablerrrr,Fs
cCs]tjtjd|�}z0tj||tj�ddtjtjB�SWdtj|�XdS)z5Steal a handle from process identified by source_pid.FrN)r.�OpenProcess�PROCESS_DUP_HANDLEr0r/r1�DUPLICATE_CLOSE_SOURCE�CloseHandle)Z
source_pidr2Zsource_process_handlerrrr-NscCs&t|tj|�}|j|�dS)z&Send a handle over a local connection.N)r+r.r1�send)�connr2�destination_pidZdhrrrrZscCs|j�j�S)z)Receive a handle over a local connection.)�recv�detach)r8rrrr_sc@s1eZdZdZddd�Zdd�ZdS)r+zPicklable wrapper for a handle.Nc
Cs�|dkrtj�}tjtjd|�}z+tjtj�|||dd�|_Wdtj|�X||_	||_
dS)NFr)�os�getpidr.r3r4r0r/�_handler6�_access�_pid)rr2�access�pid�procrrrres		zDupHandle.__init__c
Cs{|jtj�kr|jStjtjd|j�}z/tj||jtj�|j	dtj
�SWdtj|�XdS)z1Get the handle.  This should only be called once.FN)r@r<r=r>r.r3r4r0r/r?r5r6)rrCrrrr;tszDupHandle.detach)r"r#r$r%rr;rrrrr+cs�DupFd�sendfds�recvfds�darwincCs{tjd|�}tt|�dg�}|j|gtjtj|fg�trw|jd�dkrwt	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�msgrrrrE�s
%cCsHtjd�}|j|}|jdtj|��\}}}}|rW|rWt�y�trm|jd�t|�dkr�t	dt|���|d\}}	}
|tj
kr|	tjkrt|
�|jdkr�t�|j
|
�t|�d|dkst�t|�SWnttfk
r7YnXt	d��dS)	z/Receive an array of fds over an AF_UNIX socket.rHrrJzreceived %d items of ancdatarrIzInvalid data receivedN)rK�itemsizeZrecvmsgrNr
�EOFErrorrPr7rMrQrOr�
ValueErrorZ	frombytes�AssertionError�list�
IndexError)rR�size�aZ
bytes_sizerSZancdata�flagsZaddrZ
cmsg_levelZ	cmsg_typeZ	cmsg_datarrrrF�s,
'

 c
Cs?tj|j�tjtj��}t||g�WdQRXdS)z&Send a handle over a local connection.N)rN�fromfd�fileno�AF_UNIX�SOCK_STREAMrE)r8r2r9�srrrr�s$c
Cs@tj|j�tjtj��}t|d�dSWdQRXdS)z)Receive a handle over a local connection.rrN)rNr]r^r_r`rF)r8rarrrr�s$cCsatj�}|dk	r.|j|j|��StrQddlm}|j|�Std��dS)zReturn a wrapper for an fd.Nr)�resource_sharerz&SCM_RIGHTS appears not to be available)rZget_spawning_popenrDZduplicate_for_child�HAVE_SEND_HANDLE�rbrV)�fdZ	popen_objrbrrrrD�s
cCsE|jdkr(t|j|jjffSt|j|jjffSdS)N)�__self__�getattrr�__func__r")�mrrr�_reduce_method�srjc@seZdZdd�ZdS)�_CcCsdS)Nr)rrrr�f�sz_C.fN)r"r#r$rlrrrrrk�srkcCst|j|jffS)N)rg�__objclass__r")rirrr�_reduce_method_descriptor�srncCs"t|j|j|jpiffS)N)�_rebuild_partial�funcr�keywords)�prrr�_reduce_partial�srscCstj|||�S)N)�	functools�partial)rprrqrrrro�srocCs#ddlm}t||�ffS)Nr)�	DupSocket)rbrv�_rebuild_socket)rarvrrr�_reduce_socket�srxcCs
|j�S)N)r;)Zdsrrrrw�srwcCs1t|j��}t||j|j|jffS)N)rDr^rw�familyr�proto)ra�dfrrrrx�scCs%|j�}tj|||d|�S)Nr^)r;rN)r{ryrrzrerrrrw�s)+r&rtrr<r(rN�sysrdr�__all__�platform�hasattrrcZPicklerrrrr.r,r-rr�objectr+rKrPrErFrDrjrkrrlrnrX�append�int�__add__rsrorurxrwrrrr�<module>
s^	#

?>