Your IP : 18.118.164.100


Current Path : /opt/alt/python34/lib64/python3.4/multiprocessing/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/multiprocessing/__pycache__/reduction.cpython-34.pyo

�
e f��@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/python34/lib64/python3.4/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�}ntjtj�||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�}ntjtjd|�}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�trz|jd�dkrzt	d��ndS)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Cs4tjd�}|j|}|jdtj|��\}}}}|rZ|rZt�ny�trs|jd�nt|�dkr�t	dt|���n|d\}}	}
|tj
kr|	tjkrt|
�|jdkr�t�n|j
|
�t|�SWnttfk
r#YnXt	d��dS)z/Receive an array of fds over an AF_UNIX socket.rHrrJzreceived %d items of ancdatarzInvalid data receivedN)rK�itemsizeZrecvmsgrNr
�EOFErrorrPr7rMrQrOr�
ValueErrorZ	frombytes�list�
IndexError)rR�size�aZ
bytes_sizerSZancdata�flagsZaddrZ
cmsg_levelZ	cmsg_typeZ	cmsg_datarrrrF�s*
'		
c
Cs>tj|j�tjtj��}t||g�WdQXdS)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�dSWdQXdS)z)Receive a handle over a local connection.rrN)rNr\r]r^r_rF)r8r`rrrr�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�rarV)�fdZ	popen_objrarrrrD�s
cCsE|jdkr(t|j|jjffSt|j|jjffSdS)N)�__self__�getattrr�__func__r")�mrrr�_reduce_method�sric@seZdZdd�ZdS)�_CcCsdS)Nr)rrrr�f�sz_C.fN)r"r#r$rkrrrrrj�srjcCst|j|jffS)N)rf�__objclass__r")rhrrr�_reduce_method_descriptor�srmcCs"t|j|j|jpiffS)N)�_rebuild_partial�funcr�keywords)�prrr�_reduce_partial�srrcCstj|||�S)N)�	functools�partial)rorrprrrrn�srncCs#ddlm}t||�ffS)Nr)�	DupSocket)raru�_rebuild_socket)r`rurrr�_reduce_socket�srwcCs
|j�S)N)r;)Zdsrrrrv�srvcCs1t|j��}t||j|j|jffS)N)rDr]rv�familyr�proto)r`�dfrrrrw�scCs%|j�}tj|||d|�S)Nr])r;rN)rzrxrryrdrrrrv�s)+r&rsrr<r(rN�sysrcr�__all__�platform�hasattrrbZPicklerrrrr.r,r-rr�objectr+rKrPrErFrDrirjrrkrmrW�append�int�__add__rrrnrtrwrvrrrr�<module>
s^	#

?>