U e5d(%@sddlmZddlZddlZddlZddlZddlZddlZddlZddl m Z ddddd gZ ej d kpe ed oe ed oe ejd ZGdddejZejZd6dd Zej d kre dddg7Z ddlZd7ddddZddZddZddZGdddeZnHe dddg7Z ddlZej dkZddZddZd dZd!dZd"dZd#d$ZGd%d&d&Z ee!e j"ed'd(Z#ee!e$j%e#ee!e&j'e#d)d*Z(d+d,Z)eej*e(ej d krd-d.Z+d/d0Z,eeje+nd1d.Z+d2d0Z,eeje+Gd3d4d4ed5Z-dS)8)ABCMetaN)context send_handle recv_handleForkingPicklerregisterdumpwin32ZCMSG_LEN SCM_RIGHTSsendmsgcsFeZdZiZejZfddZeddZ edddZ e j Z Z S) rcs*tj||j|_|j|jdSN)super__init___copyreg_dispatch_tablecopydispatch_tableupdate_extra_reducersselfargs __class__1/usr/lib64/python3.8/multiprocessing/reduction.pyr&s  zForkingPickler.__init__cCs||j|<dSr )r)clstypereducerrrr+szForkingPickler.registerNcCs t}|||||Sr )ioBytesIOr getbuffer)robjprotocolZbufrrrdumps0szForkingPickler.dumps)N)__name__ __module__ __qualname__rcopyregrrr classmethodrr$pickleloads __classcell__rrrrr!s   cCst|||dSr )rr )r"filer#rrrr :s DupHandle duplicate steal_handleF)source_processcCs6t}|dkr|}|dkr |}t|||d|tjS)Nr)_winapiGetCurrentProcessDuplicateHandleDUPLICATE_SAME_ACCESS)handleZtarget_processZ inheritabler1Zcurrent_processrrrr/Gsc CsFttjd|}z$t||tddtjtjBWSt|XdSNFr)r2 OpenProcessPROCESS_DUP_HANDLE CloseHandler4r3r5DUPLICATE_CLOSE_SOURCE)Z source_pidr6Zsource_process_handlerrrr0Ss cCst|tj|}||dSr )r.r2r5send)connr6destination_pidZdhrrrr_scCs |Sr )recvdetach)r=rrrrdsc@seZdZdddZddZdS)r.Nc Cs\|dkrt}ttjd|}ztt|||dd|_W5t|X||_ ||_ dSr7) osgetpidr2r8r9r:r4r3_handle_access_pid)rr6accesspidprocrrrrjs  zDupHandle.__init__c CsZ|jtkr|jSttjd|j}z"t||jt |j dtj WSt|XdS)NF) rErArBrCr2r8r9r:r4r3rDr;)rrHrrrr@ys zDupHandle.detach)N)r%r&r'rr@rrrrr.hs DupFdsendfdsrecvfdsdarwincCsVtd|}tt|dg}||gtjtj|fgtrR|ddkrRt ddS)NirAz%did not receive acknowledgement of fd) arraybyteslenr socket SOL_SOCKETr ACKNOWLEDGEr? RuntimeError)sockZfdsmsgrrrrJs  c Cstd}|j|}|dt|\}}}}|s:|s:tztrJ|dt|dkrft dt||d\}} } |tj kr| tj krt| |jdkrt | | t|d|dkrtdt||dt|WSWnt tfk rYnXt ddS) NrMrrOzreceived %d items of ancdatarrNz Len is {0:n} but msg[0] is {1!r}zInvalid data received)rPitemsizeZrecvmsgrSZ CMSG_SPACEEOFErrorrUr<rRrVrTr ValueErrorZ frombytesAssertionErrorformatlist IndexError) rWsizeaZ bytes_sizerXZancdataflagsZaddrZ cmsg_levelZ cmsg_typeZ cmsg_datarrrrKs<      c Cs2t|tjtj}t||gW5QRXdSr )rSfromfdfilenoAF_UNIX SOCK_STREAMrJ)r=r6r>srrrrsc Cs<t|tjtj}t|ddW5QRSQRXdS)Nrr)rSrcrdrerfrK)r=rgrrrrscCsFt}|dk r |||Str:ddlm}||StddS)Nr)resource_sharerz&SCM_RIGHTS appears not to be available)rZget_spawning_popenrIZduplicate_for_childHAVE_SEND_HANDLErhr[)fdZ popen_objrhrrrrIs  cCs2|jdkrt|j|jjffSt|j|jjffSdSr )__self__getattrr__func__r%mrrr_reduce_methods rqc@seZdZddZdS)_CcCsdSr r)rrrrfsz_C.fN)r%r&r'rsrrrrrrsrrcCst|j|jffSr )rm __objclass__r%rorrr_reduce_method_descriptorsrucCst|j|j|jpiffSr )_rebuild_partialfuncrkeywords)prrr_reduce_partialsrzcCstj|f||Sr ) functoolspartial)rwrrxrrrrvsrvcCsddlm}t||ffS)Nr) DupSocket)rhr}_rebuild_socket)rgr}rrr_reduce_sockets rcCs|Sr )r@)Zdsrrrr~sr~cCs"t|}t||j|j|jffSr )rIrdr~familyrproto)rgdfrrrrs cCs|}tj||||dS)N)rd)r@rS)rrrrrkrrrr~sc@s`eZdZeZeZeZeZeZej dkr4e Z e Z e Z n e Z eZeZeZeZeZeZeZddZdS)AbstractReducerr cGsNtttjttttjttttj ttt j t tt j tdSr )rrrrrsrqr^appendruint__add__r{r|rzrSrrrrrrs  zAbstractReducer.__init__N)r%r&r'rrr rrsysplatformr0r/r.rJrKrIrqrurvrr~rrrrrrs$ r) metaclass)N)NF).abcrr(r{rrAr*rSrrjr__all__rhasattrriZPicklerrrr r2r/r0rrobjectr.rPrUrJrKrIrqrrrrsrur^rrrrzrvr|rr~rrrrr sj          #