grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026a ´i ã@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ÚstopÚwin32Ú DupSocketc@s eZdZdZdd„Zdd„ZdS)rzPicklable wrapper for a socket.cs(| ¡‰‡fdd„}t |ˆj¡|_dS)Ncsˆ |¡}| |¡dS©N)ÚshareÚ send_bytes)ÚconnÚpidr ©Znew_sock©ú7/usr/lib64/python3.9/multiprocessing/resource_sharer.pyÚsends z DupSocket.__init__..send)ÚdupÚ_resource_sharerÚregisterÚcloseÚ_id)ÚselfÚsockrrrrÚ__init__s zDupSocket.__init__cCsBt |j¡�"}| ¡}t |¡WdƒS1s40YdS)z1Get the socket. This should only be called once.N)rÚget_connectionrÚ recv_bytesÚsocketZ fromshare)rr r rrrÚdetach$szDupSocket.detachN©Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrrrrrsÚDupFdc@s eZdZdZdd„Zdd„ZdS)r#z-Wrapper for fd which can be used at any time.cs4t |¡‰‡fdd„}‡fdd„}t ||¡|_dS)Ncst |ˆ|¡dSr )rÚ send_handle)r r ©Znew_fdrrr1szDupFd.__init__..sendcst ˆ¡dSr )Úosrrr%rrr3szDupFd.__init__..close)r&rrrr)rÚfdrrrr%rr/s   zDupFd.__init__cCs:t |j¡�}t |¡WdƒS1s,0YdS)z-Get the fd. This should only be called once.N)rrrrÚ recv_handle)rr rrrr7sz DupFd.detachNrrrrrr#-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|_t ¡|_d|_d|_d|_t  |t j ¡dS)Nr) Ú_keyÚ_cacheÚ threadingÚLockÚ_lockÚ _listenerÚ_addressÚ_threadrÚregister_after_forkr)Ú _afterfork)rrrrr?s z_ResourceSharer.__init__cCsf|j�L|jdur| ¡|jd7_||f|j|j<|j|jfWdƒS1sX0YdS)z+Register resource, returning an identifier.Nr)r.r0Ú_startr*r+)rrrrrrrHs  z_ResourceSharer.registercCs<ddlm}|\}}||t ¡jd�}| |t ¡f¡|S)zrrrrrrZs$  ÿ     z_ResourceSharer.stopcCs\|j ¡D]\}\}}|ƒq |j ¡|j ¡|jdurF|j ¡d|_d|_d|_dSr ) r+rCrDr.Ú_at_fork_reinitr/rr0r1)rr>rrrrrr3os    z_ResourceSharer._afterforkcCsjddlm}|jdusJdƒ‚t d¡|t ¡jd�|_|jj|_ t j |j d�}d|_ | ¡||_dS)Nr)ÚListenerzAlready have Listenerz0starting listener and thread for sending handlesr7)ÚtargetT)r9rGr/rÚdebugrr:r8r=r0r,ÚThreadÚ_serveÚdaemonÚstartr1)rrGÚtrrrr4zs   z_ResourceSharer._startcCsÊttdƒrt tjt ¡¡z„|j ¡�f}| ¡}|durJWdƒWqÆ|\}}|j  |¡\}}z|||ƒW|ƒn|ƒ0Wdƒn1s”0YWqt   ¡s¾t j t  ¡ŽYq0qdS)NÚpthread_sigmask)ÚhasattrÚsignalrOÚ SIG_BLOCKÚ valid_signalsr/ÚacceptÚrecvr+ÚpoprÚ is_exitingÚsysÚ excepthookÚexc_info)rr Úmsgr>Údestination_pidrrrrrrK…s   2z_ResourceSharer._serve)N) rr r!r"rrÚ staticmethodrrr3r4rKrrrrr)=s      r))r&rQrrXr,ÚrÚcontextrrÚ__all__ÚplatformÚobjectrr#r)rrrrrrÚ s       \