Your IP : 3.145.107.223


Current Path : /opt/alt/python311/lib64/python3.11/multiprocessing/__pycache__/
Upload File :
Current File : //opt/alt/python311/lib64/python3.11/multiprocessing/__pycache__/managers.cpython-311.opt-1.pyc

�

c��fD���t�gd�ZddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZddlm
Z
ddlmZmZmZddlmZdd	lmZdd
lmZddlmZ	ddlmZd
Ze�d��n
#e$rdZYnwxYwd�Zejeje��d�dD��Zd�ZeD]Zejee���[[Gd�de��Z difd�Z!d�Z"Gd�de#��Z$d�Z%d�Z&Gd�de��Z'Gd�d e��Z(e
j)e
j*fe
j+e
j,fd!�Z-Gd"�d#e��Z.Gd$�d%e/��Z0Gd&�d'e��Z1d(�Z2ifd)�Z3		dcd*�Z4Gd+�d,e��Z5Gd-�d.e��Z6ddd/�Z7Gd0�d1e1��Z8Gd2�d3e1��Z9Gd4�d5e9��Z:Gd6�d7e1��Z;Gd8�d9e1��Z<Gd:�d;e1��Z=Gd<�d=e1��Z>e3d>d?��Z?Gd@�dAe?��Z@e3dBdC��ZAdDdEieA_Be3dFdG��ZCe3dHdI��ZDdJdJdJdEdEdK�eD_BGdL�dHeD��ZEGdM�dNe.��ZFeF�dOejG��eF�dPejG��eF�dQejHe;��eF�dRejIe9��eF�dSejJe9��eF�dTejKe9��eF�dUejLe9��eF�dVejMe:��eF�dWejNe<��eF�dXejOeE��eF�dYePe@��eF�dZeQeA��eF�d.e6e>��eF�d[e7eC��eF�d,e5e=��eF�dEe8d�\��eF�dJd�]��er+Gd^�d_��ZRGd`�dae'��ZSGdb�de.��ZTdSdS)e)�BaseManager�SyncManager�	BaseProxy�Token�N)�getpid)�
format_exc�)�
connection)�	reduction�get_spawning_popen�ProcessError)�pool)�process)�util)�get_context)�
shared_memoryT�SharedMemoryManagerFc�P�tj|j|���ffS�N)�array�typecode�tobytes)�as �?/opt/alt/python311/lib64/python3.11/multiprocessing/managers.py�reduce_arrayr/s���;���Q�Y�Y�[�[�1�1�1�c	�X�g|]'}tti|��������(S�)�type�getattr��.0�names  r�
<listcomp>r$3s3��
N�
N�
N�D�d�$�7�2�t�$�$�&�&�'�'�
N�
N�
Nr)�items�keys�valuesc�0�tt|��ffSr)�list��objs r�rebuild_as_listr,4s���$�s�)�)���rc�.�eZdZdZdZd�Zd�Zd�Zd�ZdS)rz3
    Type to uniquely identify a shared object
    ��typeid�address�idc�2�|||c|_|_|_dSrr.)�selfr/r0r1s    r�__init__zToken.__init__Ds��06���,���d�l�D�G�G�Grc�*�|j|j|jfSrr.�r3s r�__getstate__zToken.__getstate__Gs����T�\�4�7�3�3rc�0�|\|_|_|_dSrr.�r3�states  r�__setstate__zToken.__setstate__Js��/4�,���d�l�D�G�G�Grc�P�|jj�d|j�d|j�d|j�d�S)Nz(typeid=z
, address=z, id=�))�	__class__�__name__r/r0r1r6s r�__repr__zToken.__repr__Ms4����'�'�'�����d�l�l�l�D�G�G�G�M�	MrN)	r?�
__module__�__qualname__�__doc__�	__slots__r4r7r;r@rrrrr>si��������,�I�E�E�E�4�4�4�5�5�5�M�M�M�M�Mrrrc��|�||||f��|���\}}|dkr|St||���)zL
    Send a message to manager using connection `c` and return response
    �#RETURN)�send�recv�convert_to_error)�cr1�
methodname�args�kwds�kind�results       r�dispatchrPUsP���F�F�B�
�D�$�'�(�(�(��6�6�8�8�L�D�&��y����
�
�4��
(�
(�(rc	�8�|dkr|S|dvrmt|t��s1td�||t	|�������|dkrtd|z��St|��St
d�|����S)N�#ERROR)�
#TRACEBACK�#UNSERIALIZABLEz.Result {0!r} (kind '{1}') type is {2}, not strrTzUnserializable message: %s
zUnrecognized message type {!r})�
isinstance�str�	TypeError�formatr�RemoteError�
ValueError)rNrOs  rrIrI_s����x����
�	
�2�	2�	2��&�#�&�&�	1��@�G�G��D�$�v�,�,�0�0�1�1�
1��$�$�$��=��F�G�G�G��v�&�&�&��:�A�A�$�G�G�H�H�Hrc��eZdZd�ZdS)rYc�B�dt|jd��zdzS)NzM
---------------------------------------------------------------------------
rzK---------------------------------------------------------------------------)rVrLr6s r�__str__zRemoteError.__str__os ��$�s�4�9�Q�<�'8�'8�8�6�A�BrN)r?rArBr]rrrrYrYns(������C�C�C�C�CrrYc��g}t|��D]6}t||��}t|��r|�|���7|S)z4
    Return a list of names of methods of `obj`
    )�dirr �callable�append)r+�tempr#�funcs    r�all_methodsrdvsS���D��C�������s�D�!�!���D�>�>�	��K�K�������Krc�4�d�t|��D��S)zP
    Return a list of names of methods of `obj` which do not start with '_'
    c�*�g|]}|ddk�|��S)r�_rr!s  rr$z"public_methods.<locals>.<listcomp>�s!��@�@�@�T��a��C���D���r)rdr*s r�public_methodsrh�s!��A�@�[��-�-�@�@�@�@rc��eZdZdZgd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
ee
ed�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZdS)�ServerzM
    Server class which runs in a process controlled by a manager object
    )	�shutdown�create�accept_connection�get_methods�
debug_info�number_of_objects�dummy�incref�decrefc��t|t��s0td�|t	|�������||_t
j|��|_t|\}}||d���|_
|j
j|_ddi|_i|_
i|_tj��|_dS)Nz&Authkey {0!r} is type {1!s}, not bytes�)r0�backlog�0�Nr)rU�bytesrWrXr�registryr�AuthenticationString�authkey�listener_client�listenerr0�	id_to_obj�id_to_refcount�id_to_local_proxy_obj�	threading�Lock�mutex)r3rzr0r|�
serializer�Listener�Clients       rr4zServer.__init__�s����'�5�)�)�	-��8�?�?��T�'�]�]�,�,�-�-�
-�!��
��3�G�<�<���*�:�6���&�!���#�>�>�>��
��}�,����z�*��� ���%'��"��^�%�%��
�
�
rc�^�tj��|_|tj��_	tj|j���}d|_|�	��	|j�
��s3|j�d��|j�
���3n#ttf$rYnwxYwtjtjkr@t#jd��tjt_tjt_tjd��dS#tjtjkr@t#jd��tjt_tjt_tjd��wxYw)z(
        Run the server forever
        )�targetTr	zresetting stdout, stderrrN)r��Event�
stop_eventr�current_process�_manager_server�Thread�accepter�daemon�start�is_set�wait�KeyboardInterrupt�
SystemExit�sys�stdout�
__stdout__r�debug�
__stderr__�stderr�exit)r3r�s  r�
serve_foreverzServer.serve_forever�sP��$�/�+�+���48���!�!�1�	� �'�t�}�=�=�=�H�"�H�O��N�N����
��/�0�0�2�2�,��O�(�(��+�+�+��/�0�0�2�2�,���%�z�2�
�
�
���
�����z�S�^�+�+��
�5�6�6�6� �^��
� �^��
��H�Q�K�K�K�K�K��	�z�S�^�+�+��
�5�6�6�6� �^��
� �^��
��H�Q�K�K�K�K���s1�5D<�(AB5�4D<�5C	�D<�C	�	D<�<A0F,c���		|j���}n#t$rY�(wxYwtj|j|f���}d|_|����c)NT�r�rL)r~�accept�OSErrorr�r��handle_requestr�r�)r3rJ�ts   rr�zServer.accepter�st��	�
��M�(�(�*�*�����
�
�
���
����� ��(;�1�$�G�G�G�A��A�H�
�G�G�I�I�I�	s��
*�*c��d}	tj||j��tj||j��|���}|\}}}}t||��}	||g|�Ri|��}d|f}	n@#t$rdt��f}	Yn$wxYw#t$rdt��f}	YnwxYw	|�|	��dS#t$r}
	|�dt��f��n#t$rYnwxYwtj
d|	��tj
d|��tj
d|
��Yd}
~
dSd}
~
wwxYw)NrFrSzFailure to send message: %rz ... request was %r� ... exception was %r)r
�deliver_challenger|�answer_challengerHr �	ExceptionrrGr�info)r3rJ�request�ignore�funcnamerLrMrcrO�msg�es           r�_handle_requestzServer._handle_request�s�����	*��(��D�L�9�9�9��'��4�<�8�8�8��f�f�h�h�G�+2�(�F�H�d�D��4��*�*�D�
*���a�/�$�/�/�/�$�/�/��!�&�)�����
3�
3�
3�#�Z�\�\�2����
3������	/�	/�	/�����.�C�C�C�	/����		2�
�F�F�3�K�K�K�K�K���	2�	2�	2�
�����j�l�l�3�4�4�4�4���
�
�
���
�����I�3�S�9�9�9��I�+�W�5�5�5��I�-�q�1�1�1�1�1�1�1�1�1�����	2���s[�AB�$A5�5B�B�B2�1B2�6C
�
E�#C<�;E�<
D	�E�D	�	AE�Ec��	|�|��n#t$rYnwxYw|���dS#|���wxYw)z)
        Handle a new connection
        N)r�r��close�r3�conns  rr�zServer.handle_request�sc��	�� � ��&�&�&�&���	�	�	��D�	����
�J�J�L�L�L�L�L��D�J�J�L�L�L�L���s��>�
%�>�%�>�Ac�B�tjdtj��j��|j}|j}|j}|j�	���s�	dx}}|��}|\}}}	}
	||\}}}n:#t$r-}
	|j|\}}}n#t$r|
�wxYwYd}
~
nd}
~
wwxYw||vr%td|�dt|���d|�����t||��}	||	i|
��}|o|�|d��}|r7|�|||��\}}t#||j|��}d||ff}n d|f}n#t&$r}d|f}Yd}~nd}~wwxYwn�#t$rX|�d	t)��f}nB	|j|}|||||g|	�Ri|
��}d|f}n #t&$rd	t)��f}YnwxYwYnit,$rBtjd
tj��j��t/jd��Ynt&$rd	t)��f}YnwxYw		||��n)#t&$r|dt)��f��YnwxYwn�#t&$r�}tjd
tj��j��tjd|��tjd|��|���t/jd��Yd}~nd}~wwxYw|j�	�����dSdS)zQ
        Handle requests from the proxies in a particular process/thread
        z$starting server thread to service %rNzmethod z of z object is not in exposed=�#PROXYrFrRrSz$got EOF -- exiting thread serving %rrrTzexception in thread serving %rz ... message was %rr�r	)rr�r��current_threadr#rHrGrr�r��KeyErrorr��AttributeErrorrr �getrlrr0r�r�fallback_mapping�EOFErrorr�r�r�r�)r3r�rHrGrrKr+r��identrLrM�exposed�	gettypeid�ke�function�resr/�rident�rexposed�tokenr�r��
fallback_funcrOs                        r�serve_clientzServer.serve_client�sD��	
�
�9��+�-�-�2�	4�	4�	4��y���y���N�	��/�(�(�*�*�D	�5
3�#'�'�
�S��$�&�&��07�-��z�4��!�.7��.>�+�C��)�)���!�!�!�!� �6�u�=�0��W�i�i��#�!�!�!� ��!����'0�i�i�i�i�����!�����W�,�,�(�.�#���T�#�Y�Y�Y�Y���9����
#�3�
�3�3��/�"�(�D�1�D�1�1�C�'�J�9�=�=��T�+J�+J�F��/�+/�;�;�t�V�S�+I�+I�(��� %�f�d�l�F� C� C��'�(�E�):�;���(�#�.����!�(�(�(�#�Q�-�C�C�C�C�C�C�����(������"�
;�
;�
;��%�'����6�C�C�;�(,�(=�j�(I�
�!.�� �$��s�"�59�"�"�"�=A�"�"�� )�&�1����$�;�;�;�+�Z�\�\�:����;�������
�
�
��
�A�$�3�5�5�:�<�<�<����������
3�
3�
3�#�Z�\�\�2����
3����
�<��D��I�I�I�I�� �<�<�<��D�+�Z�\�\�:�;�;�;�;�;�<�������
�
�
��	�:�!�0�2�2�7�9�9�9��	�/��5�5�5��	�1�1�5�5�5��
�
�������������������

����}�/�(�(�*�*�D	�D	�D	�D	�D	s��E-�2A?�>E-�?
B6�
B�B1�
B)�)B1�,E-�1B6�6<E-�3E�;AE-�
E)�E$�E-�$E)�)E-�-H4� F,�+H4�,G	�H4�G	�	H4�AH4�H4�3H4�9I�I/�#I+�(I/�*I+�+I/�/
L�9A=K;�;Lc��|Srr�r3r�r�r+s    r�fallback_getvaluezServer.fallback_getvalue?s���
rc� �t|��Sr�rVr�s    r�fallback_strzServer.fallback_strBs
���3�x�x�rc� �t|��Sr)�reprr�s    r�
fallback_reprzServer.fallback_reprEs���C�y�y�r)r]r@�	#GETVALUEc��dSrr�r3rJs  rrqzServer.dummyNs���rc
��|j5g}t|j�����}|���|D]W}|dkrO|�d|�d|j|�dt
|j|d��dd������Xd�|��cddd��S#1swxYwYdS)	zO
        Return some info --- useful to spot problems with refcounting
        rwz  z:       refcount=z
    rN�K�
)	r�r)r�r&�sortrarVr�join)r3rJrOr&r�s     rrozServer.debug_infoQs%��
�Z�		%�		%��F���+�0�0�2�2�3�3�D��I�I�K�K�K��
H�
H���C�<�<��M�M�M�#(�5�5�$�*=�e�*D�*D�*D�#&�t�~�e�'<�Q�'?�#@�#@��"��#E�#E�#G�H�H�H���9�9�V�$�$�		%�		%�		%�		%�		%�		%�		%�		%�		%�		%�		%�		%����		%�		%�		%�		%�		%�		%s�B+C�C�Cc�*�t|j��S)z*
        Number of shared objects
        )�lenr�r�s  rrpzServer.number_of_objectsas��
�4�&�'�'�'rc��	tjd��|�d��n#ddl}|���YnxYw|j���dS#|j���wxYw)z'
        Shutdown this process
        z!manager received shutdown message�rFNrN)rr�rG�	traceback�	print_excr��set)r3rJr�s   rrkzServer.shutdownhs���	"��J�:�;�;�;�
�F�F�$�%�%�%�%��	"��������!�!�!�!�!�����O���!�!�!�!�!��D�O���!�!�!�!���s�),�A&�A�A&�&Bc	��|j5|j|\}}}}|�-|st|��dkrtd���|d}	n||i|��}	|�t	|	��}|�dt|t��s0td�|t|�������t|��t|��z}dt|	��z}
tj
d||
��|	t|��|f|j|
<|
|jvr
d|j|
<ddd��n#1swxYwY|�||
��|
t%|��fS)z>
        Create a new shared object and return its id
        Nr	z4Without callable, must have one non-keyword argumentrz,Method_to_typeid {0!r}: type {1!s}, not dictz%xz&%r callable returned object with id %r)r�rzr�rZrhrU�dictrWrXrr)r1rr�r�rr�rr�tuple)r3rJr/rLrMr`r��method_to_typeid�	proxytyper+r�s           rrlz
Server.createus����Z�	/�	/��m�F�+�
;�H�g�/�����P�C��I�I��N�N�$�N�P�P�P��1�g����h��-��-�-����(��-�-���+�!�"2�D�9�9�G�#�F�M�M�,�d�3C�.D�.D�F�F�G�G�G��w�-�-�$�/?�*@�*@�@���2�c�7�7�N�E��J�?���O�O�O�%(�#�g�,�,�8H�$I�D�N�5�!��D�/�/�/�-.��#�E�*�7	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/����	/�	/�	/�	/�:	
���A�u�����e�G�n�n�$�$s�DD*�*D.�1D.c�L�t|j|jd��S)zL
        Return the methods of the shared object indicated by token
        r	)r�rr1)r3rJr�s   rrnzServer.get_methods�s ���T�^�E�H�-�a�0�1�1�1rc��|tj��_|�d��|�|��dS)z=
        Spawn a new thread to serve this connection
        r�N)r�r�r#rGr�)r3rJr#s   rrmzServer.accept_connection�sB��+/�	� �"�"�'�	��� �!�!�!����!�����rc�D�|j5	|j|xxdz
cc<nh#t$r[}||jvrFd|j|<|j||j|<|j|\}}}tjd|��n|�Yd}~nd}~wwxYwddd��dS#1swxYwYdS)Nr	z&Server re-enabled tracking & INCREF %r)r�r�r�r�rrr�)r3rJr�r�r+r�r�s       rrrz
Server.incref�s(��
�Z�	�	�
��#�E�*�*�*�a�/�*�*�*�*���
�
�
�
�D�6�6�6�12�D�'��.��2�5�9��N�5�)�.2�n�U�.C�+�C��)��J�G��O�O�O�O��H�P�O�O�O�O�����
����	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s7�B� �B�
B�AB�;B�B�B�B�Bc	�,�||jvr ||jvrtjd|��dS|j5|j|dkr:td�||j||j|�����|j|xxdzcc<|j|dkr|j|=ddd��n#1swxYwY||jvrId|j|<tjd|��|j5|j|=ddd��dS#1swxYwYdSdS)NzServer DECREF skipping %rrz+Id {0!s} ({1!r}) has refcount {2:n}, not 1+r	)NrNzdisposing of obj with id %r)r�r�rr�r��AssertionErrorrXr)r3rJr�s   rrsz
Server.decref�s�����+�+�+��T�/�/�/��J�2�E�:�:�:��F�
�Z�	/�	/��"�5�)�Q�.�.�$�A�H�H��t�~�e�4��+�E�2�4�4�5�5�5�
���&�&�&�!�+�&�&�&��"�5�)�Q�.�.��'��.�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/����	/�	/�	/�	/���+�+�+�%5�D�N�5�!��J�4�e�<�<�<���
*�
*��N�5�)�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*����
*�
*�
*�
*�
*�
*�,�+s$�A:B7�7B;�>B;�1	D�D�DN)r?rArBrC�publicr4r�r�r�r�r�r�r�r�r�rqrorprkrlrnrmrrrsrrrrjrj�s]��������N�N�N�F�&�&�&�$���,���2�2�2�<
�
�
�O�O�O�b���������� �%�
�
��
�
�
�%�%�%� (�(�(�"�"�"�"%�"%�"%�H2�2�2�������$*�*�*�*�*rrjc� �eZdZdgZdZdZdZdS)�State�valuerr	�N)r?rArBrD�INITIAL�STARTED�SHUTDOWNrrrr�r��s$�������	�I��G��G��H�H�Hrr�)�pickle�	xmlrpclibc���eZdZdZiZeZ		ddd�d�Zd�Zd�Z	dd
�Z
e	dd���Zd�Z
dd
�Zd�Zd�Zd�Zd�Zed���Zed���Ze		dd���ZdS)rz!
    Base class for managers
    Nr�g�?)�shutdown_timeoutc�F�|�tj��j}||_tj|��|_t
��|_tj|j_	||_
t|\|_|_
|p
t��|_||_dSr)rr�r|�_addressr{�_authkeyr��_stater�r��_serializerr}�	_Listener�_Clientr�_ctx�_shutdown_timeout)r3r0r|r��ctxr�s      rr4zBaseManager.__init__�s����?��-�/�/�7�G���
��4�W�=�=��
��g�g���!�M����%���'6�z�'B�$������(�;�=�=��	�!1����rc�~�|jjtjkr~|jjtjkrtd���|jjtjkrtd���td�|jj�����t|j	|j
|j|j��S)zX
        Return server object with serve_forever() method and address attribute
        �Already started server�Manager has shut down�Unknown state {!r})
r�r�r�r�r�r
r�rXrj�	_registryr�r�r�r6s r�
get_serverzBaseManager.get_servers����;���
�-�-��{� �E�M�1�1�"�#;�<�<�<���"�e�n�4�4�"�#:�;�;�;�"�(�/�/���0A�B�B�D�D�D��d�n�d�m��m�T�%5�7�7�	7rc��t|j\}}||j|j���}t	|dd��t
j|j_dS)z>
        Connect manager object to the server process
        �r|Nrq)	r}r�r�r�rPr�r�r�r�)r3r�r�r�s    r�connectzBaseManager.connectsR��+�4�+;�<���&��v�d�m�T�]�;�;�;����t�W�%�%�%�!�M�����rrc
�b�|jjtjkr~|jjtjkrtd���|jjtjkrtd���td�|jj�����|�t|��std���tjd���\}}|j�
t|��j|j|j|j|j|||f���|_d	�d
�|jjD����}t|��jdz|z|j_|j���|���|���|_|���tj|j_t9j|t|��j|j|j|j|j|j|j fd�
��|_!dS)z@
        Spawn a server process for this manager object
        rrrNzinitializer must be a callableF)�duplexr��:c3�4K�|]}t|��V��dSrr�)r"�is  r�	<genexpr>z$BaseManager.start.<locals>.<genexpr>1s(����A�A�A��Q���A�A�A�A�A�Ar�-r�rL�exitpriority)"r�r�r�r�r�r
r�rXr`rWr
�Piper��Processr�_run_serverrr�r�r��_processr��	_identityr?r#r�r�rHr�Finalize�_finalize_managerr�r�rk)r3�initializer�initargs�reader�writerr�s      rr�zBaseManager.starts����;���
�-�-��{� �E�M�1�1�"�#;�<�<�<���"�e�n�4�4�"�#:�;�;�;�"�(�/�/���0A�B�B�D�D�D��"�8�K�+@�+@�"��<�=�=�=�$���6�6�6�����	�)�)���:�:�)��.�$�-����"�F�K��C�*����
�
���A�A���)@�A�A�A�A�A��!�$�Z�Z�0�C�7�%�?��
���
������	���������
�
��
�������"�M�����
��$�t�*�*�.��-����
�t�{��,�� 6�8��	����
�
�
rc�N�tjtjtj��|�||�|�||||��}|�|j��|���tjd|j��|�	��dS)z@
        Create a server, report its address and run it
        Nzmanager serving at %r)
�signal�SIGINT�SIG_IGN�_ServerrGr0r�rr�r�)	�clsrzr0r|r�rrr�servers	         rrzBaseManager._run_serverCs���	�
�f�m�V�^�4�4�4��"��K��"�"����X�w���D�D��	���F�N�#�#�#�������	
�	�)�6�>�:�:�:��������rc��|�|j|j���}	t|dd|f|z|��\}}|���n#|���wxYwt||j|��|fS)zP
        Create a new shared object; return the token and exposed tuple
        rNrl)r�r�r�rPr�r)r3r/rLrMr�r1r�s       r�_createzBaseManager._createZs{��
�|�|�D�M�4�=�|�A�A��	�"�4��x�&��4���N�N�K�B���J�J�L�L�L�L��D�J�J�L�L�L�L�����V�T�]�B�/�/��8�8s�A�A(c��|j�<|j�|��|j���sd|_dSdSdS)zC
        Join the manager process (if it has been spawned)
        N)rr��is_alive�r3�timeouts  rr�zBaseManager.joinfsU���=�$��M���w�'�'�'��=�)�)�+�+�
%� $��
�
�
�%�$�
%�
%rc���|�|j|j���}	t|dd��|���S#|���wxYw)zS
        Return some info about the servers shared objects and connections
        rNro�r�r�r�rPr�r�s  r�_debug_infozBaseManager._debug_infoosR���|�|�D�M�4�=�|�A�A��	��D�$��5�5��J�J�L�L�L�L��D�J�J�L�L�L�L�����A�Ac���|�|j|j���}	t|dd��|���S#|���wxYw)z5
        Return the number of shared objects
        rNrpr*r�s  r�_number_of_objectszBaseManager._number_of_objectsysS���|�|�D�M�4�=�|�A�A��	��D�$�(;�<�<��J�J�L�L�L�L��D�J�J�L�L�L�L���r,c��|jjtjkr|���|jjtjkr~|jjtjkrt
d���|jjtjkrt
d���t
d�|jj�����|S)NzUnable to start serverrr)	r�r�r�r�r�r�r
r�rXr6s r�	__enter__zBaseManager.__enter__�s����;���
�-�-��J�J�L�L�L��;���
�-�-��{� �E�M�1�1�"�#;�<�<�<���"�e�n�4�4�"�#:�;�;�;�"�(�/�/���0A�B�B�D�D�D��rc�.�|���dSr)rk�r3�exc_type�exc_val�exc_tbs    r�__exit__zBaseManager.__exit__�s���
�
�����rc���|j���r,tjd��	|||���}	t|dd��|���n#|���wxYwn#t
$rYnwxYw|j|���|j��r�tjd��t|d��rutjd��|j��|j|���|j��r2tjd	��|j	��|j��tj|_	tj|=dS#t$rYdSwxYw)
zQ
        Shutdown the manager process; will be registered as a finalizer
        z#sending shutdown message to managerrNrk)r(zmanager still alive�	terminatez'trying to `terminate()` manager processz#manager still alive after terminate)r&rr�rPr�r�r��hasattrr8�killr�r�r�r�_address_to_localr�)rr0r|r:r�r�r�s       rrzBaseManager._finalize_manager�s����7����	'��I�;�<�<�<�
��w�w��8�8�8��!��T�4��4�4�4��J�J�L�L�L�L��D�J�J�L�L�L�L����L���
�
�
���
����
�G�L�!1�2�2�2�2��w��!�!�	
'��	�/�0�0�0��7�K�0�0�'��I�G�H�H�H�%�G�%�'�'�'� �G�L�)9�:�:�:�:�'�w�'�)�)�'��	�"G�H�H�H�$������$�������n���	��+�G�4�4�4���	�	�	��D�D�	���s:�
A4�A�A4�A0�0A4�4
B�B�
E�
E,�+E,c��|jSr)r�r6s rr0zBaseManager.address�s
���}�rTc�h���d|jvr|j���|_��t�|pt	�dd��}|pt	�dd��}|r't|�����D]\}}�|||�f|j�<|r ��fd�}	�|	_t|�|	��dSdS)z9
        Register a typeid with the manager type
        rN�	_exposed_�_method_to_typeid_c���tjd���|j�g|�Ri|��\}}�||j||j|���}|�|j|j���}t|dd|jf��|S)Nz)requesting creation of a shared %r object��managerr|r�rrs)	rr�r$r�r�r�r0rPr1)	r3rLrMr��exp�proxyr�r�r/s	       ��rrbz"BaseManager.register.<locals>.temp�s�����
�F��O�O�O�)�T�\�&�@�4�@�@�@�4�@�@�
��s�!�	��4�+�T� �M�3������|�|�E�M�4�=�|�I�I����t�X���{�;�;�;��r)	�__dict__r�copy�	AutoProxyr r)r%r?�setattr)
r!r/r`r�r�r��
create_method�keyr�rbs
 ` `      r�registerzBaseManager.register�s�����c�l�*�*��M�.�.�0�0�C�M���!�I��B�W�Y��T�B�B��+�J�"�9�.B�D�I�I�	��	H�"�#3�#9�#9�#;�#;�<�<�
H�
H�
��U�U�

�g�/��!��
�f���	'�	
�	
�	
�	
�	
�	
�#�D�M��C���&�&�&�&�&�	'�	'r)NNr�Nrxr)NNNNT)r?rArBrCrrjr r4rrr��classmethodrr$r�r+r.r0r6�staticmethodr�propertyr0rKrrrrr�sc���������I��G�>F��2�/2�2�2�2�2�2�
7�
7�
7�*�*�*�)�)�)�)�V�/1�����[��,
9�
9�
9�%�%�%�%�������������� � ��\� �D����X���EI�6:�%'�%'�%'��[�%'�%'�%'rrc��eZdZd�Zd�ZdS)�ProcessLocalSetc�2�tj|d���dS)Nc�*�|���Sr)�clearr*s r�<lambda>z*ProcessLocalSet.__init__.<locals>.<lambda>�s��3�9�9�;�;�r)r�register_after_forkr6s rr4zProcessLocalSet.__init__�s��� ��'>�'>�?�?�?�?�?rc�$�t|��dfSrx)rr6s r�
__reduce__zProcessLocalSet.__reduce__�s���D�z�z�2�~�rN)r?rArBr4rWrrrrPrP�s5������@�@�@�����rrPc��eZdZdZiZej��Z		dd�Zd�Z	difd�Z
d	�Zd
�Ze
d���Zd�Zd
�Zd�Zd�Zd�ZdS)rz.
    A base for proxies of shared objects
    NTFc���tj5tj�|jd��}|�5tj��t��f}|tj|j<ddd��n#1swxYwY|d|_|d|_	||_
|j
j|_||_
||_t|d|_||_|�t%j|��|_n6|j
�|j
j|_nt%j��j|_|r|���tj|tj��dS)Nrr	)r�_mutexr;r�r0r�ForkAwareLocalrP�_tls�_idset�_tokenr1�_id�_managerr�r}r��_owned_by_managerrr{r�r�r|�_increfrU�_after_fork)	r3r�r�rBr|r�rr�
manager_owned�	tls_idsets	         rr4zBaseProxy.__init__�s���
�
�	G�	G�!�3�7�7��
�t�L�L�I�� � �/�1�1�?�3D�3D�D�	�=F�	�+�E�M�:�		G�	G�	G�	G�	G�	G�	G�	G�	G�	G�	G����	G�	G�	G�	G��a�L��	�
 ��l�������;�>�����
�%���&�z�2�1�5���"/�����#�8��A�A�D�M�M�
�]�
&� �M�2�D�M�M�#�3�5�5�=�D�M��	��L�L�N�N�N�� ��y�'<�=�=�=�=�=s�AA6�6A:�=A:c�\�tjd��tj��j}tj��jdkr|dtj��jzz
}|�|jj	|j
���}t|dd|f��||j_
dS)Nzmaking connection to manager�
MainThread�|rrm)rr�rr�r#r�r�r�r^r0r�rPr\r
)r3r#r�s   r�_connectzBaseProxy._connect s����
�1�2�2�2��&�(�(�-���#�%�%�*�l�:�:��C�)�2�4�4�9�9�9�D��|�|�D�K�/���|�G�G����t�0�4�'�:�:�:�#��	���rrc��	|jj}n[#t$rNtjdtj��j��|���|jj}YnwxYw|�	|j
|||f��|���\}}|dkr|S|dkr�|\}}|jj
|jd}	|jj|_|	||j|j|j|���}
|�|j|j���}t)|dd|jf��|
St-||���)	zV
        Try to call a method of the referent and return a copy of the result
        z#thread %r does not own a connectionrFr����rArNrs)r\r
r�rr�r�r�r#rirGr_rHr`rr/r^r0r�r�r�rPr1rI)r3rKrLrMr�rNrOr�r�r�rDs           r�_callmethodzBaseProxy._callmethod)sV��	(��9�'�D�D���	(�	(�	(��J�<� �/�1�1�6�
8�
8�
8��M�M�O�O�O��9�'�D�D�D�		(����	
�	�	�4�8�Z��t�4�5�5�5��y�y�{�{���f��9����M�
�X�
�
�#�N�G�U��
�/���=�b�A�I� �K�/�E�M��I��t�'����
�w����E��<�<��
�t�}�<�E�E�D��T�4��E�H�;�7�7�7��L��t�V�,�,�,s��AA'�&A'c�,�|�d��S)z9
        Get a copy of the value of the referent
        r��rlr6s r�	_getvaluezBaseProxy._getvalueGs������,�,�,rc
��|jr!tjd|jj��dS|�|jj|j���}t|dd|j	f��tjd|jj��|j
�|j	��|jo|jj
}tj|tj|j|j||j|j
|jfd���|_dS)Nz%owned_by_manager skipped INCREF of %rrrrz	INCREF %r�
r)rarr�r^r1r�r0r�rPr_r]�addr`r�rr�_decrefr\�_close)r3r�r:s   rrbzBaseProxy._increfMs����!�	��J�>����O�O�O��F��|�|�D�K�/���|�G�G����t�X���{�3�3�3��
�;����/�/�/�������!�!�!��
�6�$�-�"6���m��)�#��+�t�}�e��)�T�[�$�,�8��	������rc�8�|�|j��|�|jtjkrr	tjd|j��||j|���}t|dd|jf��nF#t$r}tjd|��Yd}~n"d}~wwxYwtjd|j��|sXt|d��rJtjdtj��j
��|j���|`dSdSdS)Nz	DECREF %rrrsz... decref failed %sz%DECREF %r -- manager already shutdownr
z-thread %r has no more proxies so closing conn)�discardr1r�r�r�rr�r0rPr�r9r�r�r#r
r�)r�r|r:�tls�idsetr�r�r�s        rrszBaseProxy._decrefas?��
�
�
�e�h�����=�E�K�5�=�8�8�
6��
�;���1�1�1��w�u�}�g�>�>�>����t�X���{�;�;�;�;���
6�
6�
6��
�1�1�5�5�5�5�5�5�5�5�����
6����
�J�>���I�I�I��	���l�3�3�	��J�F� �/�1�1�6�
8�
8�
8��N� � �"�"�"�����		�	�	�	s�AA8�8
B!�B�B!c��d|_	|���dS#t$r"}tjd|z��Yd}~dSd}~wwxYw)Nzincref failed: %s)r`rbr�rr�)r3r�s  rrczBaseProxy._after_forkzsf����
�	/��L�L�N�N�N�N�N���	/�	/�	/��I�)�A�-�.�.�.�.�.�.�.�.�.�����	/���s��
A�A�Ac���i}t���
|j|d<t|dd��r&|j|d<tt
|j|j|ffStt|��|j|j|ffS)Nr|�_isautoFr�)	rr�r r>�RebuildProxyrGr^r�r�r3rMs  rrWzBaseProxy.__reduce__�s��������+�"�m�D��O��4��E�*�*�	G�"�n�D��O� ����T�-=�t�D�F�
F�!��$�Z�Z���d�.>��E�G�
Grc�*�|���Sr)ro)r3�memos  r�__deepcopy__zBaseProxy.__deepcopy__�s���~�~���rc�d�dt|��j|jjt	|��fzS)Nz<%s object, typeid %r at %#x>)rr?r^r/r1r6s rr@zBaseProxy.__repr__�s/��.��T�
�
�#�T�[�%7��D���B�C�	Crc��	|�d��S#t$rt|��dd�dzcYSwxYw)zV
        Return representation of the referent (or a fall-back if that fails)
        r@Nrkz; '__str__()' failed>)rlr�r�r6s rr]zBaseProxy.__str__�sV��	=��#�#�J�/�/�/���	=�	=�	=���:�:�c�r�c�?�%<�<�<�<�<�	=���s��$>�>�NNNTF)r?rArBrCr;r�ForkAwareThreadLockrZr4rirlrorbrMrsrcrWr�r@r]rrrrr�s����������
%�T�
%�
'�
'�F�26�HM�'>�'>�'>�'>�R$�$�$�,.�B�-�-�-�-�<-�-�-����(����\��0/�/�/�G�G�G� � � �C�C�C�=�=�=�=�=rrc��ttj��dd��}|rW|j|jkrGt	jd|��d|d<|j|jvr|j|j|j|j<|�	dd��o"ttj��dd��}|||fd|i|��S)	z5
    Function used for unpickling proxy objects.
    r�Nz*Rebuild a proxy owned by manager, token=%rTrdrr�_inheritingF)
r rr�r0rr�r1r�r�pop)rcr�r�rMr"rrs      rr|r|�s����W�,�.�.�0A�4�
H�
H�F�
�+�&�.�E�M�1�1��
�?��G�G�G� $��_���8�6�7�7�7�� ���*�
�(���2�	
����4� � �	E��G�+�-�-�}�e�D�D�D���4��z�9�9�&�9�D�9�9�9rc���t|��}	|||fS#t$rYnwxYwi}|D]}td|�d|�d�|���t|tf|��}||_||||f<|S)zB
    Return a proxy type whose methods are given by `exposed`
    zdef z:(self, /, *args, **kwds):
        return self._callmethod(z
, args, kwds))r�r��execrrr>)r#r��_cache�dic�meth�	ProxyTypes      r�
MakeProxyTyper��s����G�n�n�G�
��t�W�o�&�&���
�
�
���
����
�C��H�H����6:�d�d�D�D�D�B�CF�	H�	H�	H�	H��T�I�<��-�-�I�!�I��'�F�D�'�?���s�	�
(�(c��t|d}|�T||j|���}	t|dd|f��}|���n#|���wxYw|�	|�|j}|�tj��j}td|j	z|��}	|	||||||���}
d|
_
|
S)z*
    Return an auto-proxy for `token`
    r	Nrrnz
AutoProxy[%s])rBr|rrrdT)r}r0rPr�r�rr�r|r�r/r{)r�r�rBr|r�rrrdr�r�r�rDs           rrGrG�s���
�j�)�!�,�G����w�u�}�g�6�6�6��	��t�T�=�5�(�C�C�G��J�J�L�L�L�L��D�J�J�L�L�L�L������7�.��"�����)�+�+�3���o���<�g�F�F�I��I�e�Z��'�#�=�
B�
B�
B�E��E�M��Ls�A�A'c��eZdZd�Zd�ZdS)�	Namespacec�:�|j�|��dSr)rE�updater}s  rr4zNamespace.__init__�s���
���T�"�"�"�"�"rc�2�t|j�����}g}|D]4\}}|�d��s|�|�d|�����5|���|jj�dd�|���d�S)Nrg�=�(�, r=)	r)rEr%�
startswithrar�r>r?r�)r3r%rbr#r�s     rr@zNamespace.__repr__�s����T�]�(�(�*�*�+�+���� �	5�	5�K�D�%��?�?�3�'�'�
5����t�t�t�U�U�3�4�4�4���	�	�����>�2�2�2�D�I�I�d�O�O�O�O�D�DrN)r?rArBr4r@rrrr�r��s7������#�#�#�E�E�E�E�Err�c�@�eZdZdd�Zd�Zd�Zd�Zeee��ZdS)�ValueTc�"�||_||_dSr)�	_typecode�_value)r3rr��locks    rr4zValue.__init__�s��!�������rc��|jSr�r�r6s rr�z	Value.get�s
���{�rc��||_dSrr��r3r�s  rr�z	Value.set�s
������rc�P�t|��j�d|j�d|j�d�S)Nr�r�r=)rr?r�r�r6s rr@zValue.__repr__�s*��!�$�Z�Z�0�0�0�$�.�.�.�$�+�+�+�N�NrN�T)	r?rArBr4r�r�r@rNr�rrrr�r��sc����������������O�O�O��H�S�#���E�E�Err�c�,�tj||��Sr)r)r�sequencer�s   r�Arrayr�s���;�x��*�*�*rc�0�eZdZdZd�Zd�Zd�Zd�Zd�ZdS)�
IteratorProxy)�__next__rG�throwr�c��|Srrr6s r�__iter__zIteratorProxy.__iter__����rc�.�|�d|��S)Nr�rn�r3rLs  rr�zIteratorProxy.__next__s�����
�D�1�1�1rc�.�|�d|��S)NrGrnr�s  rrGzIteratorProxy.sends�������-�-�-rc�.�|�d|��S)Nr�rnr�s  rr�zIteratorProxy.throw��������.�.�.rc�.�|�d|��S)Nr�rnr�s  rr�zIteratorProxy.closer�rN)	r?rArBr>r�r�rGr�r�rrrr�r�
sd������6�I����2�2�2�.�.�.�/�/�/�/�/�/�/�/rr�c�,�eZdZdZdd�Zd�Zd�Zd�ZdS)	�
AcquirerProxy)�acquire�releaseTNc�@�|�|fn||f}|�d|��S�Nr�rn)r3�blockingr(rLs    rr�zAcquirerProxy.acquires,��%�o��{�{�H�g�3F�����	�4�0�0�0rc�,�|�d��S�Nr�rnr6s rr�zAcquirerProxy.release������	�*�*�*rc�,�|�d��Sr�rnr6s rr0zAcquirerProxy.__enter__r�rc�,�|�d��Sr�rnr2s    rr6zAcquirerProxy.__exit__!r�r)TN)r?rArBr>r�r�r0r6rrrr�r�sZ������&�I�1�1�1�1�+�+�+�+�+�+�+�+�+�+�+rr�c�0�eZdZdZdd�Zd	d�Zd�Zdd�ZdS)
�ConditionProxy)r�r�r��notify�
notify_allNc�0�|�d|f��S�Nr�rnr's  rr�zConditionProxy.wait'��������
�3�3�3rr	c�0�|�d|f��S)Nr�rn)r3�ns  rr�zConditionProxy.notify)s������1�$�/�/�/rc�,�|�d��S)Nr�rnr6s rr�zConditionProxy.notify_all+s������-�-�-rc���|��}|r|S|�tj��|z}nd}d}|s@|�|tj��z
}|dkrn!|�|��|��}|�@|S)Nr)�time�	monotonicr�)r3�	predicater(rO�endtime�waittimes      r�wait_forzConditionProxy.wait_for-s���������	��M����n�&�&��0�G�G��G��H��	!��"�"�T�^�%5�%5�5���q�=�=���I�I�h�����Y�[�[�F�
�	!��
rr)r	)r?rArBr>r�r�r�r�rrrr�r�%sd������F�I�4�4�4�4�0�0�0�0�.�.�.������rr�c�,�eZdZdZd�Zd�Zd�Zdd�ZdS)�
EventProxy)r�r�rSr�c�,�|�d��S)Nr�rnr6s rr�zEventProxy.is_setBs������)�)�)rc�,�|�d��S�Nr�rnr6s rr�zEventProxy.setD�������&�&�&rc�,�|�d��S)NrSrnr6s rrSzEventProxy.clearF�������(�(�(rNc�0�|�d|f��Sr�rnr's  rr�zEventProxy.waitHr�rr)r?rArBr>r�r�rSr�rrrr�r�@sZ������2�I�*�*�*�'�'�'�)�)�)�4�4�4�4�4�4rr�c�h�eZdZdZd	d�Zd�Zd�Zed���Zed���Z	ed���Z
dS)
�BarrierProxy)�__getattribute__r��abort�resetNc�0�|�d|f��Sr�rnr's  rr�zBarrierProxy.waitNr�rc�,�|�d��S)Nr�rnr6s rr�zBarrierProxy.abortPr�rc�,�|�d��S)Nr�rnr6s rr�zBarrierProxy.resetRr�rc�.�|�dd��S)Nr�)�partiesrnr6s rr�zBarrierProxy.partiesTs����� 2�L�A�A�Arc�.�|�dd��S)Nr�)�	n_waitingrnr6s rr�zBarrierProxy.n_waitingWs����� 2�N�C�C�Crc�.�|�dd��S)Nr�)�brokenrnr6s rr�zBarrierProxy.brokenZs����� 2�K�@�@�@rr)r?rArBr>r�r�r�rNr�r�r�rrrr�r�Ls�������>�I�4�4�4�4�)�)�)�)�)�)�
�B�B��X�B�
�D�D��X�D�
�A�A��X�A�A�Arr�c�$�eZdZdZd�Zd�Zd�ZdS)�NamespaceProxy)r��__setattr__�__delattr__c��|ddkrt�||��St�|d��}|d|f��S)Nrrgrlr�)�objectr��r3rJ�
callmethods   r�__getattr__zNamespaceProxy.__getattr__asO���q�6�S�=�=��*�*�4��5�5�5��,�,�T�=�A�A�
��z�,�s�f�5�5�5rc��|ddkrt�|||��St�|d��}|d||f��S)Nrrgrlr�)r�r�r�)r3rJr�r�s    rr�zNamespaceProxy.__setattr__fsR���q�6�S�=�=��%�%�d�C��7�7�7��,�,�T�=�A�A�
��z�-�#�u��6�6�6rc��|ddkrt�||��St�|d��}|d|f��S)Nrrgrlr�)r�r�r�r�s   rr�zNamespaceProxy.__delattr__ksN���q�6�S�=�=��%�%�d�C�0�0�0��,�,�T�=�A�A�
��z�-�#��0�0�0rN)r?rArBr>r�r�r�rrrr�r�_sF������B�I�6�6�6�
7�7�7�
1�1�1�1�1rr�c�V�eZdZdZd�Zd�Zeee��Zee	j
��ZdS)�
ValueProxy)r�r�c�,�|�d��S)Nr�rnr6s rr�zValueProxy.gettr�rc�0�|�d|f��Sr�rnr�s  rr�zValueProxy.setvs�������x�0�0�0rN)r?rArBr>r�r�rNr�rL�types�GenericAlias�__class_getitem__rrrr�r�rsW�������I�'�'�'�1�1�1��H�S�#���E�#��E�$6�7�7���rr��
BaseListProxy)�__add__�__contains__�__delitem__�__getitem__�__len__�__mul__�__reversed__�__rmul__�__setitem__ra�count�extend�index�insertr��remove�reverser��__imul__c��eZdZd�Zd�ZdS)�	ListProxyc�4�|�d|f��|S)Nrrnr�s  r�__iadd__zListProxy.__iadd__�s������E�8�,�,�,��rc�4�|�d|f��|S)Nrrnr�s  rrzListProxy.__imul__�s������e�X�.�.�.��rN)r?rArBrrrrrr
r
�s2�������������rr
�	DictProxy)r�r�r�r�rrrSrFr�r%r&r��popitem�
setdefaultr�r'r��Iterator�
ArrayProxy)rr�r�	PoolProxy)�apply�apply_asyncr��imap�imap_unorderedr��map�	map_async�starmap�
starmap_asyncr8�AsyncResult)rrrrrc��eZdZd�Zd�ZdS)rc��|Srrr6s rr0zPoolProxy.__enter__�r�rc�.�|���dSr)r8r2s    rr6zPoolProxy.__exit__�s���������rN)r?rArBr0r6rrrrr�s2�������������rc��eZdZdZdS)ra(
    Subclass of `BaseManager` which supports a number of shared object types.

    The types registered are those intended for the synchronization
    of threads, plus `dict`, `list` and `Namespace`.

    The `multiprocessing.Manager()` function creates started instances of
    this class.
    N)r?rArBrCrrrrr�s���������rr�Queue�
JoinableQueuer�r��RLock�	Semaphore�BoundedSemaphore�	Condition�Barrier�Poolr)r�r�)r�rI)rIc�@�eZdZdZgfd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	S)
�_SharedMemoryTrackerz+Manages one or more shared memory segments.c�"�||_||_dSr��shared_memory_context_name�
segment_names)r3r#r1s   rr4z_SharedMemoryTracker.__init__�s��.2�D�+�!.�D���rc��tjd|�dt������|j�|��dS)z6Adds the supplied shared memory block name to tracker.zRegister segment � in pid N)rr�rr1ra�r3�segment_names  r�register_segmentz%_SharedMemoryTracker.register_segment�sD���J�M�<�M�M�6�8�8�M�M�N�N�N���%�%�l�3�3�3�3�3rc��tjd|�dt������|j�|��tj|��}|���|���dS)z�Calls unlink() on the shared memory block with the supplied name
            and removes it from the list of blocks being tracked.zDestroy segment r3N)	rr�rr1r	r�SharedMemoryr��unlink)r3r5�segments   r�destroy_segmentz$_SharedMemoryTracker.destroy_segment�ss��
�J�L�,�L�L�&�(�(�L�L�M�M�M���%�%�l�3�3�3�#�0��>�>�G��M�M�O�O�O��N�N�����rc�T�|jdd�D]}|�|���dS)z<Calls destroy_segment() on all tracked shared memory blocks.N)r1r;r4s  rr9z_SharedMemoryTracker.unlink�s>�� $� 2�1�1�1� 5�
3�
3���$�$�\�2�2�2�2�
3�
3rc��tjd|jj�dt	������|���dS)NzCall z.__del__ in )rr�r>r?rr9r6s r�__del__z_SharedMemoryTracker.__del__�s=���J�N�t�~�6�N�N�F�H�H�N�N�O�O�O��K�K�M�M�M�M�Mrc��|j|jfSrr/r6s rr7z!_SharedMemoryTracker.__getstate__�s���3�T�5G�H�Hrc��|j|�dSr)r4r9s  rr;z!_SharedMemoryTracker.__setstate__�s���D�M�5�!�!�!�!rN)r?rArBrCr4r6r;r9r>r7r;rrrr-r-�s�������5�5�/1�	/�	/�	/�	/�	4�	4�	4�
	�	�	�	3�	3�	3�
	�	�	�	I�	I�	I�	"�	"�	"�	"�	"rr-c�J�eZdZejgd�zZd�Zd�Zd�Zd�Zd�Z	d�Z
dS)	�SharedMemoryServer)�
track_segment�release_segment�
list_segmentsc�"�tj|g|�Ri|��|j}t|t��rtj|��}td|�dt������|_	tjdt������dS)N�shm_rgz"SharedMemoryServer started by pid )rjr4r0rUry�os�fsdecoder-r�shared_memory_contextrr�)r3rL�kwargsr0s    rr4zSharedMemoryServer.__init__�s����O�D�2�4�2�2�2�6�2�2�2��l�G��'�5�)�)�
/��+�g�.�.��$�%@�G�%@�%@�f�h�h�%@�%@�A�A�
�&��J�F�F�H�H�F�F�G�G�G�G�Grc��t|j|dd��r
|j|d<tj|||g|�Ri|��S)z�Create a new distributed-shared object (not backed by a shared
            memory block) and return its id to be used in a Proxy Object.rk�_shared_memory_proxyrJ)r9rzrJrjrl)r3rJr/rLrKs     rrlzSharedMemoryServer.create	sV���t�}�V�,�R�0�2H�I�I�
M�26�2L��.�/��=��q�&�B�4�B�B�B�6�B�B�Brc�j�|j���t�||��S)zACall unlink() on all tracked shared memory, terminate the Server.)rJr9rjrkr�s  rrkzSharedMemoryServer.shutdowns+���&�-�-�/�/�/��?�?�4��+�+�+rc�:�|j�|��dS)z?Adds the supplied shared memory block name to Server's tracker.N)rJr6�r3rJr5s   rrCz SharedMemoryServer.track_segments���&�7�7��E�E�E�E�Erc�:�|j�|��dS)z�Calls unlink() on the shared memory block with the supplied name
            and removes it from the tracker instance inside the Server.N)rJr;rPs   rrDz"SharedMemoryServer.release_segments!��
�&�6�6�|�D�D�D�D�Drc��|jjS)zbReturns a list of names of shared memory blocks that the Server
            is currently tracking.)rJr1r�s  rrEz SharedMemoryServer.list_segments!s���-�;�;rN)r?rArBrjr�r4rlrkrCrDrErrrrBrB�s���������F�F�F�G��	H�	H�	H�	C�	C�	C�	,�	,�	,�
	F�	F�	F�	E�	E�	E�
	<�	<�	<�	<�	<rrBc�4�eZdZdZeZd�Zd�Zd�Zd�Z	d�Z
dS)ra�Like SyncManager but uses SharedMemoryServer instead of Server.

        It provides methods for creating and returning SharedMemory instances
        and for creating a list-like object (ShareableList) backed by shared
        memory.  It also provides methods that create and return Proxy Objects
        that support synchronization across processes (i.e. multi-process-safe
        locks and semaphores).
        c���tjdkrddlm}|���tj|g|�Ri|��tj|j	j
�dt������dS)N�posixr	)�resource_trackerz created by pid )rHr#�rV�ensure_runningrr4rr�r>r?r)r3rLrKrVs    rr4zSharedMemoryManager.__init__3s����w�'�!�!�/�.�.�.�.�.� �/�/�1�1�1�� ��7��7�7�7��7�7�7��J�$�.�1�M�M�6�8�8�M�M�N�N�N�N�Nrc�d�tj|jj�dt	������dS)Nz.__del__ by pid )rr�r>r?rr6s rr>zSharedMemoryManager.__del__?s/���J�$�.�1�M�M�6�8�8�M�M�N�N�N�N�Nrc��|jjtjkr~|jjtjkrtd���|jjtjkrtd���td�|jj�����|�|j	|j
|j|j��S)z@Better than monkeypatching for now; merge into Server ultimatelyz"Already started SharedMemoryServerz!SharedMemoryManager has shut downr)
r�r�r�r�r�r
r�rXr rr�r�r�r6s rrzSharedMemoryManager.get_serverBs����{� �E�M�1�1��;�$��
�5�5�&�'K�L�L�L��[�&�%�.�8�8�&�'J�K�K�K�&�,�3�3�D�K�4E�F�F�H�H�H��<�<����
� $�
�t�/?�A�A�
Arc�,�|�|j|j���5}tjdd|���}	t|dd|jf��n(#t$r}|���|�d}~wwxYw	ddd��n#1swxYwY|S)zoReturns a new SharedMemory instance with the specified size in
            bytes, to be tracked by the manager.rNT)rl�sizerC)	r�r�r�rr8rPr#�
BaseExceptionr9)r3r\r��smsr�s     rr8z SharedMemoryManager.SharedMemoryOs������d�m�T�]��C�C�
�t�#�0��d��N�N�N����T�4��3�8�+�F�F�F�F��$�����J�J�L�L�L��G���������G�
�
�
�
�
�
�
�
�
�
�
����
�
�
�
��Js4�B	�A�B	�
A9�A4�4A9�9B	�	B
�B
c�:�|�|j|j���5}tj|��}	t|dd|jjf��n-#t$r }|j�	��|�d}~wwxYw	ddd��n#1swxYwY|S)z�Returns a new ShareableList instance populated with the values
            from the input sequence, to be tracked by the manager.rNrC)
r�r�r�r�
ShareableListrP�shmr#r]r9)r3r�r��slr�s     rr`z!SharedMemoryManager.ShareableList[s������d�m�T�]��C�C�
�t�"�0��:�:����T�4��2�6�;�.�I�I�I�I��$�����F�M�M�O�O�O��G���������J�
�
�
�
�
�
�
�
�
�
�
����
�
�
�
��Is4�B�A�B�
B� A;�;B�B�B�BN)r?rArBrCrBr r4r>rr8r`rrrrr'sy������	�	�%��
	O�
	O�
	O�	O�	O�	O�	A�	A�	A�
	�
	�
	�
	�
	�
	�
	�
	rr�r�)U�__all__r�r�rr�queuer�r�rHrr�rrWr
�contextrrr
rrrrr�	HAS_SHMEMra�ImportErrorrrK�
view_typesr,�	view_typer�rrPrIr�rYrdrhrjr�r�r��XmlListener�	XmlClientr}rr�rPrr|r�rGr�r�r�r�r�r�r�r�r�r�r�r
rr?r�
BasePoolProxyrrr$r�r�r&r'r(r)r*r+r)r�r-rBrrrr�<module>rms���A�
@�
@���
�
�
�����
�
�
�
�����������������	�	�	�	������� � � � � � �������@�@�@�@�@�@�@�@�@�@�������������������������*��������I��N�N�(�)�)�)�)��	�����I�I�I�����2�2�2��	��5�;��-�-�-�
N�
N�4M�
N�
N�
N�
�����3�3�I��I��y�/�2�2�2�2�
�z�M�M�M�M�M�F�M�M�M�.&(�b�)�)�)�)�
I�
I�
I�C�C�C�C�C�)�C�C�C�	�	�	�A�A�A�G*�G*�G*�G*�G*�V�G*�G*�G*�\
�����F�����#�Z�%6�7��)�:�+?�@����t'�t'�t'�t'�t'�&�t'�t'�t'�t�����c����m=�m=�m=�m=�m=��m=�m=�m=�f:�:�:�*)+�����,8<�7<�����:
E�
E�
E�
E�
E��
E�
E�
E�
�
�
�
�
�F�
�
�
�+�+�+�+�/�/�/�/�/�I�/�/�/�
+�
+�
+�
+�
+�I�
+�
+�
+������]����6	4�	4�	4�	4�	4��	4�	4�	4�A�A�A�A�A�9�A�A�A�&1�1�1�1�1�Y�1�1�1�&8�8�8�8�8��8�8�8��
�o�0���
������
����
�M�+�(�
�
�	��
� �	��
�]�<�*���
�
�
�k�,���
�
!��"�� �$�$�
� ������
����	�	�	�	�	�+�	�	�	����W�e�k�*�*�*����_�e�k�2�2�2����W�i�o�z�:�:�:����V�Y�^�]�;�;�;����W�i�o�}�=�=�=����[�)�"5�}�E�E�E����'��)C�"�$�$�$����[�)�"5�~�F�F�F����Y�	� 1�<�@�@�@����V�T�Y�	�2�2�2����V�T�9�-�-�-����V�T�9�-�-�-����W�e�Z�0�0�0����W�e�Z�0�0�0����[�)�^�<�<�<����Z�=���N�N�N����]�%��8�8�8�
�Q�""�""�""�""�""�""�""�""�J*<�*<�*<�*<�*<�V�*<�*<�*<�Z>�>�>�>�>�k�>�>�>�>�>�gQ�Qs�A8�8B�B

?>