U e5dèã@s²ddlZddlZddlZddlZddlZddlmZddlmZddlm Z dgZ ej dkrxe dg7Z Gd d„de ƒZ ne d g7Z Gd d „d e ƒZGd d „d e ƒZeƒZejZdS)éNé)Úprocess)Ú reduction)ÚutilÚstopZwin32Ú DupSocketc@s eZdZdZdd„Zdd„ZdS)rzPicklable wrapper for a socket.cs(| ¡‰‡fdd„}t |ˆj¡|_dS)Ncsˆ |¡}| |¡dS©N)ÚshareZ send_bytes)ÚconnÚpidr ©Znew_sock©ú7/usr/lib64/python3.8/multiprocessing/resource_sharer.pyÚsends z DupSocket.__init__..send)ÚdupÚ_resource_sharerÚregisterÚcloseÚ_id)ÚselfZsockrr r rÚ__init__s zDupSocket.__init__c Cs6t |j¡ }| ¡}t |¡W5QR£SQRXdS)z1Get the socket. This should only be called once.N)rÚget_connectionrZ recv_bytesÚsocketZ fromshare)rr r r r rÚdetach$szDupSocket.detachN©Ú__name__Ú __module__Ú __qualname__Ú__doc__rrr r r rrsÚDupFdc@s eZdZdZdd„Zdd„ZdS)rz-Wrapper for fd which can be used at any time.cs4t |¡‰‡fdd„}‡fdd„}t ||¡|_dS)Ncst |ˆ|¡dSr)rZ send_handle)r r ©Znew_fdr rr1szDupFd.__init__..sendcst ˆ¡dSr)Úosrr r r rr3szDupFd.__init__..close)r!rrrr)rÚfdrrr r rr/s   zDupFd.__init__c Cs.t |j¡}t |¡W5QR£SQRXdS)z-Get the fd. This should only be called once.N)rrrrZ recv_handle)rr r r rr7sz DupFd.detachNrr r r rr-sc@sNeZdZdZdd„Zdd„Zedd„ƒZdd d „Zd d „Z d d„Z dd„Z dS)Ú_ResourceSharerz.Manager for resources using background thread.cCs@d|_i|_g|_t ¡|_d|_d|_d|_t   |t j ¡dS)Nr) Ú_keyÚ_cacheÚ _old_locksÚ threadingÚLockÚ_lockÚ _listenerÚ_addressÚ_threadrZregister_after_forkr#Ú _afterfork)rr r rr?s z_ResourceSharer.__init__c CsZ|jJ|jdkr| ¡|jd7_||f|j|j<|j|jfW5QR£SQRXdS)z+Register resource, returning an identifier.Nr)r)r+Ú_startr$r%)rrrr r rrIs  z_ResourceSharer.registercCs<ddlm}|\}}||t ¡jd}| |t ¡f¡|S)z s       `