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_RIGHTSsendmsgcsJeZdZdZiZejZfddZe ddZ e d ddZ e j Z ZS) rz)Pickler subclass used by multiprocessing.cs*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)z&Register a reduce function for a type.N)r)clstypereducerrrr +szForkingPickler.registerNcCs tj}|||j||jS)N)ioBytesIOr getbuffer)robjprotocolZbufrrrdumps0szForkingPickler.dumps)N)__name__ __module__ __qualname____doc__rcopyregrrr classmethodr r"pickleloads __classcell__rr)rrr!s   cCst||j|dS)z3Replacement for pickle.dump() using ForkingPickler.N)rr )r filer!rrrr :s DupHandle duplicate steal_handleFcCs*|dkrtj}tjtj||d|tjS)zr?r@r0r5r6r2r1rAr7r8)rrErrrr=us  zDupHandle.detach)N)r#r$r%r&rr=rrrrr-ds DupFdsendfdsrecvfdsdarwincCsVtjd|}tt|dg}|j|gtjtj|fgtrR|jddkrRt ddS)z,Send an array of fds over an AF_UNIX socket.irAz%did not receive acknowledgement of fdN) arraybyteslenr socket SOL_SOCKETr ACKNOWLEDGEr< RuntimeError)sockZfdsmsgrrrrGs  c Cstjd}|j|}|jdtj|\}}}}| r>| r>tyxtrN|jdt|dkrjt dt||d\}} } |tj kr| tj krt| |jdkrt |j | t|SWnt tfk rYnXt ddS)z/Receive an array of fds over an AF_UNIX socket.rJrrLzreceived %d items of ancdatarzInvalid data receivedN)rMitemsizeZrecvmsgrPZ CMSG_SPACEEOFErrorrRr9rOrSrQr ValueErrorZ frombyteslist IndexError) rTsizeaZ bytes_sizerUZancdataflagsZaddrZ cmsg_levelZ cmsg_typeZ cmsg_datarrrrHs*          c Cs2tj|jtjtj}t||gWdQRXdS)z&Send a handle over a local connection.N)rPfromfdfilenoAF_UNIX SOCK_STREAMrG)r:r4r;srrrrsc Cs0tj|jtjtj}t|ddSQRXdS)z)Receive a handle over a local connection.rrN)rPr^r_r`rarH)r:rbrrrrscCsFtj}|dk r |j|j|Str:ddlm}|j|StddS)zReturn a wrapper for an fd.Nr)resource_sharerz&SCM_RIGHTS appears not to be available)rZget_spawning_popenrFZduplicate_for_childHAVE_SEND_HANDLErcrX)fdZ popen_objrcrrrrFs  cCs2|jdkrt|j|jjffSt|j|jjffSdS)N)__self__getattrr__func__r#)mrrr_reduce_methods rkc@seZdZddZdS)_CcCsdS)Nr)rrrrfsz_C.fN)r#r$r%rmrrrrrlsrlcCst|j|jffS)N)rh __objclass__r#)rjrrr_reduce_method_descriptorsrocCst|j|j|jpiffS)N)_rebuild_partialfuncrkeywords)prrr_reduce_partialsrtcCstj|f||S)N) functoolspartial)rqrrrrrrrpsrpcCsddlm}t||ffS)Nr) DupSocket)rcrw_rebuild_socket)rbrwrrr_reduce_sockets rycCs|jS)N)r=)ZdsrrrrxsrxcCs"t|j}t||j|j|jffS)N)rFr_rxfamilyrproto)rbdfrrrrys cCs|j}tj||||dS)N)r_)r=rP)r|rzrr{rfrrrrxsc@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 tdS)N)r rrlrmrkrYappendroint__add__rurvrtrPry)rrrrrr s  zAbstractReducer.__init__N)r#r$r%r&rr r rrsysplatformr/r.r-rGrHrFrkrorpryrxrrrrrr}s& r}) metaclass)N)NF)/abcrrr'rurr>r)rPrrer__all__rhasattrrdZPicklerrr r r0r.r/rrobjectr-rMrRrGrHrFrkrlrrmrorYr~rrrtrprvryrxr}rrrr sb         #