[@sddlZddlZddlZddlZddlZddlZddlZddlmZdddddgZ ej d kpe ed oe ed oe ejd Z Gd ddej ZejZdddZej d krfe dddg7Z ddlZddddZddZddZddZGdddeZnje dddg7Z ddlZej dkZddZddZddZddZd dZd!d"ZGd#d$d$Zeeej ed%d&Z!eee"j#e!eee$j%e!d'd(Z&d)d*Z'eej(e&ej d krd+d,Z)d-d.Z*eeje)n(d/d,Z)d0d.Z*eeje)dS)1N)context send_handle recv_handleForkingPicklerregisterdumpZwin32CMSG_LEN SCM_RIGHTSsendmsgcsgeZdZdZiZejZfddZe ddZ e dddZ e j Z S) rz)Pickler subclass used by multiprocessing.cs9tj||jj|_|jj|jdS)N)super__init___copyreg_dispatch_tablecopydispatch_tableupdate_extra_reducers)selfargs) __class__//usr/lib/python3.4/multiprocessing/reduction.pyr %szForkingPickler.__init__cCs||j|r4r5)rrBrrrr:ts zDupHandle.detach)r!r"r#r$r r:rrrrr*cs DupFdsendfdsrecvfdsdarwincCs~tjd|}tt|dg}|j|gtjtj|fgtrz|jddkrzt dndS)z,Send an array of fds over an AF_UNIX socket.irAz%did not receive acknowledgement of fdN) arraybyteslenr socket SOL_SOCKETr ACKNOWLEDGEr9 RuntimeError)sockZfdsmsgrrrrDs %c CsTtjd}|j|}|jdtj|\}}}}| rZ| rZtnytrs|jdnt|dkrt dt|n|d\}} } |tj kr(| tj kr(t| |jdkrt n|j | t|d|dkstt|SWnt tfk rCYnXt ddS) z/Receive an array of fds over an AF_UNIX socket.rGrrIzreceived %d items of ancdatarrHzInvalid data receivedN)rJitemsizeZrecvmsgrMr EOFErrorrOr6rLrPrNr ValueErrorZ frombytesAssertionErrorlist IndexError) rQsizeaZ bytes_sizerRZancdataflagsZaddrZ cmsg_levelZ cmsg_typeZ cmsg_datarrrrEs, '    c Cs>tj|jtjtj}t||gWdQXdS)z&Send a handle over a local connection.N)rMfromfdfilenoAF_UNIX SOCK_STREAMrD)r7r1r8srrrrs$c Cs?tj|jtjtj}t|ddSWdQXdS)z)Receive a handle over a local connection.rrN)rMr\r]r^r_rE)r7r`rrrrs$cCsatj}|dk r.|j|j|StrQddlm}|j|StddS)zReturn a wrapper for an fd.Nr)resource_sharerz&SCM_RIGHTS appears not to be available)rZget_spawning_popenrCZduplicate_for_childHAVE_SEND_HANDLErarU)fdZ popen_objrarrrrCs   cCsE|jdkr(t|j|jjffSt|j|jjffSdS)N)__self__getattrr__func__r!)mrrr_reduce_methodsric@seZdZddZdS)_CcCsdS)Nr)rrrrfsz_C.fN)r!r"r#rkrrrrrjs rjcCst|j|jffS)N)rf __objclass__r!)rhrrr_reduce_method_descriptorsrmcCs"t|j|j|jpiffS)N)_rebuild_partialfuncrkeywords)prrr_reduce_partialsrrcCstj|||S)N) functoolspartial)rorrprrrrnsrncCs#ddlm}t||ffS)Nr) DupSocket)raru_rebuild_socket)r`rurrr_reduce_socketsrwcCs |jS)N)r:)ZdsrrrrvsrvcCs1t|j}t||j|j|jffS)N)rCr]rvfamilyrproto)r`dfrrrrwscCs%|j}tj|||d|S)Nr])r:rM)rzrxrryrdrrrrvs )+r%rsrr;r'rMsysrcr__all__platformhasattrrbZPicklerrrrr-r+r,rrobjectr*rJrOrDrErCrirjrrkrmrWappendint__add__rrrnrtrwrvrrrr s^           #