3 \@sddlZddlZddlZddlZddlZddlmZddlmZddlm Z dgZ ej dkrxe dg7Z Gd dde Z ne d g7Z Gd d d e ZGd d d e ZeZejZdS)N)process) reduction)utilstopZwin32 DupSocketc@s eZdZdZddZddZdS)rzPicklable wrapper for a socket.cs(|jfdd}tj|j|_dS)Ncsj|}|j|dS)N)shareZ send_bytes)connpidr)new_sock7/usr/lib64/python3.6/multiprocessing/resource_sharer.pysends z DupSocket.__init__..send)dup_resource_sharerregisterclose_id)selfZsockrr )r r __init__s zDupSocket.__init__c Cs*tj|j}|j}tj|SQRXdS)z1Get the socket. This should only be called once.N)rget_connectionrZ recv_bytessocketZ fromshare)rr rr r r detach$szDupSocket.detachN)__name__ __module__ __qualname____doc__rrr r r r rsDupFdc@s eZdZdZddZddZdS)rz-Wrapper for fd which can be used at any time.cs4tj|fdd}fdd}tj|||_dS)Ncstj||dS)N)rZ send_handle)r r )new_fdr r r1szDupFd.__init__..sendcstjdS)N)osrr )rr r r3szDupFd.__init__..close)rrrrr)rfdrrr )rr r/s   zDupFd.__init__c Cs"tj|j }tj|SQRXdS)z-Get the fd. This should only be called once.N)rrrrZ recv_handle)rr r r r r7sz DupFd.detachN)rrrrrrr r r r r-sc@sNeZdZdZddZddZeddZdd d Zd d Z d dZ ddZ dS)_ResourceSharerz-Manager for resouces using background thread.cCs@d|_i|_g|_tj|_d|_d|_d|_t j |t j dS)Nr) _key_cache _old_locks threadingLock_lock _listener_address_threadrZregister_after_forkr! _afterfork)rr r r r?s z_ResourceSharer.__init__c CsN|j>|jdkr|j|jd7_||f|j|j<|j|jfSQRXdS)z+Register resource, returning an identifier.Nr)r'r)_startr"r#)rrrr r r rIs  z_ResourceSharer.registercCs<ddlm}|\}}||tjjd}|j|tjf|S)z s       `