관리-도구
편집 파일: resource_sharer.cpython-39.pyc
a �����DOg����������������������@���s����d�dl�Z�d�dlZd�dlZd�dlZd�dlZddlmZ�ddlmZ�ddlm Z �dgZ ejdkrxe dg7�Z G�d d��de�Z ne d g7�Z G�dd ��d e�ZG�dd ��d e�Ze��ZejZdS�)�����N����)�process)� reduction)�util�stop�win32� DupSocketc�������������������@���s ���e�Zd�ZdZdd��Zdd��ZdS�)r���zPicklable wrapper for a socket.c��������������������s(���|��������fdd�}t�|��j�|�_d�S�)Nc��������������������s�������|�}|��|��d�S��N)�share� send_bytes)�conn�pidr ����Znew_sock���7/usr/lib64/python3.9/multiprocessing/resource_sharer.py�send���s���� z DupSocket.__init__.<locals>.send)�dup�_resource_sharer�register�close�_id)�self�sockr���r���r���r����__init__���s����zDupSocket.__init__c�����������������C���sB���t��|�j��"}|���}t�|�W��d����S�1�s40����Y��dS�)z1Get the socket. This should only be called once.N)r����get_connectionr���� recv_bytes�socketZ fromshare)r���r���r ���r���r���r����detach$���s����zDupSocket.detachN��__name__� __module__�__qualname__�__doc__r���r���r���r���r���r���r������s����DupFdc�������������������@���s ���e�Zd�ZdZdd��Zdd��ZdS�)r#���z-Wrapper for fd which can be used at any time.c��������������������s4���t��|�����fdd�}��fdd�}t�||�|�_d�S�)Nc��������������������s���t��|���|��d�S�r ���)r����send_handle)r���r ����Znew_fdr���r���r���1���s����zDupFd.__init__.<locals>.sendc����������������������s���t������d�S�r ���)�osr���r���r%���r���r���r���3���s����zDupFd.__init__.<locals>.close)r&���r���r���r���r���)r����fdr���r���r���r%���r���r���/���s���� zDupFd.__init__c�����������������C���s:���t��|�j��}t�|�W��d����S�1�s,0����Y��dS�)z-Get the fd. This should only be called once.N)r���r���r���r����recv_handle)r���r���r���r���r���r���7���s����zDupFd.detachNr���r���r���r���r���r#���-���s���c�������������������@���sN���e�Zd�ZdZdd��Zdd��Zedd���Zdd d �Zdd��Z d d��Z dd��ZdS�)�_ResourceSharerz.Manager for resources using background thread.c�����������������C���s:���d|�_�i�|�_t���|�_d�|�_d�|�_d�|�_t� |�t j��d�S�)Nr���)�_key�_cache� threading�Lock�_lock� _listener�_address�_threadr����register_after_forkr)���� _afterfork)r���r���r���r���r���?���s���� z_ResourceSharer.__init__c�����������������C���sf���|�j��L�|�jdu�r|�����|��jd7��_||f|�j|�j<�|�j|�jfW��d����S�1�sX0����Y��dS�)z+Register resource, returning an identifier.Nr���)r.���r0����_startr*���r+���)r���r���r���r���r���r���r���H���s���� z_ResourceSharer.registerc�����������������C���s<���ddl�m}�|�\}}||t���jd�}|�|t���f��|S�)z<Return connection from which to receive identified resource.r�����Client��authkey)� connectionr6���r����current_processr8���r���r&����getpid)�identr6����address�key�cr���r���r���r���Q���s ����z_ResourceSharer.get_connectionNc�����������������C���s����ddl�m}�|�j���|�jdur�||�jt���jd�}|�d��|����|�j � |��|�j ���rdt� d��|�j����d|�_ d|�_d|�_|�j���D�]\}\}}|���q�|�j����W�d����n1�s�0����Y��dS�)z:Stop the background thread and clear registered resources.r���r5���Nr7���z._ResourceSharer thread did not stop when asked)r9���r6���r.���r0���r���r:���r8���r���r���r1����join�is_aliver����sub_warningr/���r+����items�clear)r����timeoutr6���r?���r>���r���r���r���r���r���r���Z���s$���� � z_ResourceSharer.stopc�����������������C���s\���|�j����D�]\}\}}|���q |�j�����|�j����|�jd�urF|�j����d�|�_d�|�_d�|�_d�S�r ���) r+���rC���rD���r.����_at_fork_reinitr/���r���r0���r1���)r���r>���r���r���r���r���r���r3���o���s���� z_ResourceSharer._afterforkc�����������������C���sj���ddl�m}�|�jd�u�sJ�d��t�d��|t���jd�|�_|�jj|�_ t j|�jd�}d|_ |����||�_d�S�)Nr���)�ListenerzAlready have Listenerz0starting listener and thread for sending handlesr7���)�targetT)r9���rG���r/���r����debugr���r:���r8���r=���r0���r,����Thread�_serve�daemon�startr1���)r���rG����tr���r���r���r4���z���s���� z_ResourceSharer._startc�����������������C���s����t�td�rt�tjt�����z�|�j����f}|���}|d�u�rJW�d�����W�q�|\}}|�j� |�\}}z|||��W�|���n|���0�W�d�����n1�s�0����Y��W�q���t ���s�tj t������Y�q0�qd�S�)N�pthread_sigmask)�hasattr�signalrO���� SIG_BLOCK� valid_signalsr/����accept�recvr+����popr���� is_exiting�sys� excepthook�exc_info)r���r����msgr>����destination_pidr���r���r���r���r���rK�������s���� 2z_ResourceSharer._serve)N)r���r ���r!���r"���r���r����staticmethodr���r���r3���r4���rK���r���r���r���r���r)���=���s��� r)���)r&���rQ���r���rX���r,�����r����contextr���r����__all__�platform�objectr���r#���r)���r���r���r���r���r���r����<module>���s ��� \