3 \ $@sddlmZmZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddddd gZ e j d kpeed oeed oeejd ZGdddejZejZd5dd Ze j d kre dddg7Z ddlZd6ddZddZddZddZGdddeZnHe dddg7Z ddlZe j dkZddZddZddZd dZd!dZd"d#Z Gd$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)e j d krd,d-Z,d.d/Z-eeje,nd0d-Z,d1d/Z-eeje,Gd2d3d3ed4Z.dS)7)ABCMetaabstractmethodN)context send_handle recv_handleForkingPicklerregisterdumpwin32ZCMSG_LEN SCM_RIGHTSsendmsgcsFeZdZiZejZfddZeddZ edddZ e j Z Z S) rcs*tj||jj|_|jj|jdS)N)super__init___copyreg_dispatch_tablecopydispatch_tableupdate_extra_reducers)selfargs) __class__1/usr/lib64/python3.6/multiprocessing/reduction.pyr&s  zForkingPickler.__init__cCs||j|<dS)N)r)clstypereducerrrr +szForkingPickler.registerNcCs tj}|||j||jS)N)ioBytesIOr getbuffer)robjprotocolZbufrrrdumps0szForkingPickler.dumps)N)__name__ __module__ __qualname__rcopyregrrr classmethodr r"pickleloads __classcell__rr)rrr!s   cCst||j|dS)N)rr )r filer!rrrr :s DupHandle duplicate steal_handleFcCs*|dkrtj}tjtj||d|tjS)Nr)_winapiGetCurrentProcessDuplicateHandleDUPLICATE_SAME_ACCESS)handleZtarget_processZ inheritablerrrr-Gs  cCsBtjtjd|}z tj||tjddtjtjBStj|XdS)NFr)r/ OpenProcessPROCESS_DUP_HANDLEr1r0r2DUPLICATE_CLOSE_SOURCE CloseHandle)Z source_pidr3Zsource_process_handlerrrr.Os  cCst|tj|}|j|dS)N)r,r/r2send)connr3destination_pidZdhrrrr[scCs |jjS)N)recvdetach)r9rrrr`sc@seZdZdddZddZdS)r,Nc Cs\|dkrtj}tjtjd|}ztjtj|||dd|_Wdtj|X||_ ||_ dS)NFr) osgetpidr/r4r5r1r0_handler7_access_pid)rr3accesspidprocrrrrfs zDupHandle.__init__c CsV|jtjkr|jStjtjd|j}ztj||jtj|j dtj Stj |XdS)NF) rAr=r>r?r/r4r5r1r0r@r6r7)rrDrrrr<us  zDupHandle.detach)N)r#r$r%rr<rrrrr,ds DupFdsendfdsrecvfdsdarwincCsVtjd|}tt|dg}|j|gtjtj|fgtrR|jddkrRt ddS)NirAz%did not receive acknowledgement of fd) arraybyteslenr socket SOL_SOCKETr ACKNOWLEDGEr; RuntimeError)sockZfdsmsgrrrrFs  c Cstjd}|j|}|jdtj|\}}}}| r>| r>tyxtrN|jdt|dkrjt dt||d\}} } |tj kr| tj krt| |jdkrt |j | t|SWnt tfk rYnXt ddS)NrIrrKzreceived %d items of ancdatarzInvalid data received)rLitemsizeZrecvmsgrOZ CMSG_SPACEEOFErrorrQr8rNrRrPr ValueErrorZ frombyteslist IndexError) rSsizeaZ bytes_sizerTZancdataflagsZaddrZ cmsg_levelZ cmsg_typeZ cmsg_datarrrrGs*          c Cs2tj|jtjtj}t||gWdQRXdS)N)rOfromfdfilenoAF_UNIX SOCK_STREAMrF)r9r3r:srrrrsc Cs0tj|jtjtj}t|ddSQRXdS)Nrr)rOr]r^r_r`rG)r9rarrrrscCsFtj}|dk r |j|j|Str:ddlm}|j|StddS)Nr)resource_sharerz&SCM_RIGHTS appears not to be available)rZget_spawning_popenrEZduplicate_for_childHAVE_SEND_HANDLErbrW)fdZ popen_objrbrrrrEs  cCs2|jdkrt|j|jjffSt|j|jjffSdS)N)__self__getattrr__func__r#)mrrr_reduce_methods rjc@seZdZddZdS)_CcCsdS)Nr)rrrrfsz_C.fN)r#r$r%rlrrrrrksrkcCst|j|jffS)N)rg __objclass__r#)rirrr_reduce_method_descriptorsrncCst|j|j|jpiffS)N)_rebuild_partialfuncrkeywords)prrr_reduce_partialsrscCstj|f||S)N) functoolspartial)rprrqrrrrosrocCsddlm}t||ffS)Nr) DupSocket)rbrv_rebuild_socket)rarvrrr_reduce_sockets rxcCs|jS)N)r<)ZdsrrrrwsrwcCs"t|j}t||j|j|jffS)N)rEr^rwfamilyrproto)radfrrrrxs cCs|j}tj||||dS)N)r^)r<rO)r{ryrrzrerrrrwsc@s`eZdZeZeZeZeZeZej dkr4e Z e Z e Z n e Z eZeZeZeZeZeZeZddZdS)AbstractReducerr cGsNtttjttttjttttj ttt j t tt j tdS)N)r rrkrlrjrXappendrnint__add__rtrursrOrx)rrrrrr s  zAbstractReducer.__init__N)r#r$r%rr r rrsysplatformr.r-r,rFrGrErjrnrorxrwrrrrrr|s$ r|) metaclass)N)NF)/abcrrr&rtrr=r(rOrrdr__all__rhasattrrcZPicklerrr r r/r-r.rrobjectr,rLrQrFrGrErjrkrrlrnrXr}r~rrsrorurxrwr|rrrr sb         #