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_RIGHTSsendmsgcsJeZdZdZiZejZfddZe ddZ e d ddZ e j Z ZS) rz)Pickler subclass used by multiprocessing.cs*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|<dS)z&Register a reduce function for a type.N)r)clstypereducerrrr+szForkingPickler.registerNcCs t}|||||Sr )ioBytesIOr getbuffer)robjprotocolZbufrrrdumps0szForkingPickler.dumps)N)__name__ __module__ __qualname____doc__rcopyregrrr classmethodrr$pickleloads __classcell__rrrrr!s   cCst|||dS)z3Replacement for pickle.dump() using ForkingPickler.N)rr )r"filer#rrrr :s DupHandle duplicate steal_handleF)source_processcCs6t}|dkr|}|dkr |}t|||d|tjS)zrrrrdsc@s"eZdZdZdddZddZdS)r/zPicklable wrapper for a handle.Nc Cs\|dkrt}ttjd|}ztt|||dd|_W5t|X||_ ||_ dS)NFr) osgetpidr3r8r9r:r5r4_handle_access_pid)rr7accesspidprocrrrrjs  zDupHandle.__init__c CsZ|jtkr|jSttjd|j}z"t||jt |j dtj WSt|XdS)z1Get the handle. This should only be called once.FN) rGrCrDrEr3r8r9r:r5r4rFr;)rrJrrrrBys zDupHandle.detach)N)r%r&r'r(rrBrrrrr/hs DupFdsendfdsrecvfdsdarwincCsVtd|}tt|dg}||gtjtj|fgtrR|ddkrRt ddS)z,Send an array of fds over an AF_UNIX socket.irAz%did not receive acknowledgement of fdN) arraybyteslenr socket SOL_SOCKETr ACKNOWLEDGErA RuntimeError)sockZfdsmsgrrrrLs  c Cstd}|j|}|dt|\}}}}|s:|s:tztrJ|dt|dkrft dt||d\}} } |tj kr| tj krt| |jdkrt | | t|d|dkrtdt||dt|WSWnt tfk rYnXt dd S) z/Receive an array of fds over an AF_UNIX socket.rOrrQzreceived %d items of ancdatarrPz Len is {0:n} but msg[0] is {1!r}zInvalid data receivedN)rRitemsizeZrecvmsgrUZ CMSG_SPACEEOFErrorrWr=rTrXrVr ValueErrorZ frombytesAssertionErrorformatlist IndexError) rYsizeaZ bytes_sizerZZancdataflagsZaddrZ cmsg_levelZ cmsg_typeZ cmsg_datarrrrMs<      c Cs2t|tjtj}t||gW5QRXdSr<)rUfromfdfilenoAF_UNIX SOCK_STREAMrL)r>r7r?srrrrsc Cs<t|tjtj}t|ddW5QRSQRXdS)r@rrN)rUrerfrgrhrM)r>rirrrrscCsFt}|dk r |||Str:ddlm}||StddS)zReturn a wrapper for an fd.Nr)resource_sharerz&SCM_RIGHTS appears not to be available)rZget_spawning_popenrKZduplicate_for_childHAVE_SEND_HANDLErjr])fdZ popen_objrjrrrrKs  cCs2|jdkrt|j|jjffSt|j|jjffSdSr )__self__getattrr__func__r%mrrr_reduce_methods rsc@seZdZddZdS)_CcCsdSr r)rrrrfsz_C.fN)r%r&r'rurrrrrtsrtcCst|j|jffSr )ro __objclass__r%rqrrr_reduce_method_descriptorsrwcCst|j|j|jpiffSr )_rebuild_partialfuncrkeywords)prrr_reduce_partialsr|cCstj|f||Sr ) functoolspartial)ryrrzrrrrxsrxcCsddlm}t||ffS)Nr) DupSocket)rjr_rebuild_socket)rirrrr_reduce_sockets rcCs|Sr )rB)ZdsrrrrsrcCs"t|}t||j|j|jffSr )rKrfrfamilyrproto)ridfrrrrs cCs|}tj||||dS)N)rf)rBrU)rrrrrmrrrrsc@sdeZdZdZeZeZeZeZeZe j dkr8e Z e Z e Z n eZeZeZeZeZeZeZeZddZdS)AbstractReducerzAbstract base class for use in implementing a Reduction class suitable for use in replacing the standard reduction mechanism used in multiprocessing.r cGsNtttjttttjttttj ttt j t tt j tdSr )rrrtrursr`appendrwint__add__r}r~r|rUrrrrrrs  zAbstractReducer.__init__N)r%r&r'r(rrr rrsysplatformr1r0r/rLrMrKrsrwrxrrrrrrrrs& r) metaclass)N)NF).abcrr)r}rrCr+rUrrlr__all__rhasattrrkZPicklerrrr r3r0r1rrobjectr/rRrWrLrMrKrsrtrrurwr`rrrr|rxr~rrrrrrr sj          #