AlkantarClanX12

Your IP : 18.116.52.43


Current Path : /opt/alt/python38/lib64/python3.8/multiprocessing/__pycache__/
Upload File :
Current File : //opt/alt/python38/lib64/python3.8/multiprocessing/__pycache__/managers.cpython-38.opt-2.pyc

U

i�f��@sBdddddgZddlZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
d	d
lmZd	dl
mZmZmZd	dlmZd	d
lmZd	dlmZd	dlmZzd	dlmZdZWnek
r�dZYnXdd�Ze�eje�dd�dD�Zedek	�r.dd�ZeD]Ze�ee��qGdd�de�Zdifdd�Z dd�Z!Gd d!�d!e"�Z#d"d#�Z$d$d%�Z%Gd&d'�d'e�Z&Gd(d)�d)e�Z'ej(ej)fej*ej+fd*�Z,Gd+d�de�Z-Gd,d-�d-e.�Z/Gd.d�de�Z0d/d0�Z1ifd1d2�Z2dld3d4�Z3Gd5d6�d6e�Z4Gd7d8�d8e�Z5dmd9d:�Z6Gd;d<�d<e0�Z7Gd=d>�d>e0�Z8Gd?d@�d@e8�Z9GdAdB�dBe0�Z:GdCdD�dDe0�Z;GdEdF�dFe0�Z<GdGdH�dHe0�Z=e2dIdJ�Z>GdKdL�dLe>�Z?e2dMdN�Z@dOdPie@_Ae2dQdR�ZBe2dSdT�ZCdUdUdUdPdPdV�eC_AGdWdS�dSeC�ZDGdXd�de-�ZEeE�dYejF�eE�dZejF�eE�d[ejGe:�eE�d\ejHe8�eE�d]ejIe8�eE�d^ejJe8�eE�d_ejKe8�eE�d`ejLe9�eE�daejMe;�eE�dbejNeD�eE�dcee?�eE�ddeOe@�eE�d8e5e=�eE�d:e6eB�eE�d6e4e<�eEjdPe7dde�eEjdUddf�e�r>Gdgdh�dh�ZPGdidj�dje&�ZQGdkd�de-�ZRdS)n�BaseManager�SyncManager�	BaseProxy�Token�SharedMemoryManager�N)�getpid)�
format_exc�)�
connection)�	reduction�get_spawning_popen�ProcessError)�pool)�process)�util)�get_context)�
shared_memoryTFcCstj|j|��ffS�N)�array�typecode�tobytes)�a�r�=/opt/alt/python38/lib64/python3.8/multiprocessing/managers.py�reduce_array-srcCsg|]}tti|����qSr)�type�getattr��.0�namerrr�
<listcomp>1sr )�items�keys�valuescCstt|�ffSr)�list��objrrr�rebuild_as_list3sr'c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)r��typeid�address�idcCs||||_|_|_dSrr()�selfr)r*r+rrr�__init__BszToken.__init__cCs|j|j|jfSrr(�r,rrr�__getstate__EszToken.__getstate__cCs|\|_|_|_dSrr(�r,�staterrr�__setstate__HszToken.__setstate__cCsd|jj|j|j|jfS)Nz %s(typeid=%r, address=%r, id=%r))�	__class__�__name__r)r*r+r.rrr�__repr__Ks�zToken.__repr__N)r4�
__module__�__qualname__�	__slots__r-r/r2r5rrrrr<s
rcCs8|�||||f�|��\}}|dkr*|St||��dS)N�#RETURN)�send�recv�convert_to_error)�cr+�
methodname�args�kwds�kind�resultrrr�dispatchSs
rCcCsd|dkr|S|dkrRt|t�s4td�||t|����|dkrHtd|�St|�Sntd�|��SdS)N�#ERROR)�
#TRACEBACK�#UNSERIALIZABLEz.Result {0!r} (kind '{1}') type is {2}, not strrFzUnserializable message: %s
zUnrecognized message type {!r})�
isinstance�str�	TypeError�formatr�RemoteError�
ValueError)rArBrrrr<]s
��
r<c@seZdZdd�ZdS)rKcCsdt|jd�dS)NzM
---------------------------------------------------------------------------
rzK---------------------------------------------------------------------------)rHr?r.rrr�__str__mszRemoteError.__str__N)r4r6r7rMrrrrrKlsrKcCs2g}t|�D] }t||�}t|�r|�|�q|Sr)�dirr�callable�append)r&�tempr�funcrrr�all_methodsts
rScCsdd�t|�D�S)NcSsg|]}|ddkr|�qS)r�_rrrrrr �sz"public_methods.<locals>.<listcomp>)rSr%rrr�public_methodssrUc	@s�eZdZddddddddd	g	Zd
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Z	dd�Z
dd�Ze
ee	d�Zdd�Z
dd�Zdd �Zd!d"�Zd#d$�Zd%e_d&d'�Zd(d)�Zd*d+�Zd,d-�Zd.S)/�Server�shutdown�create�accept_connection�get_methods�
debug_info�number_of_objects�dummy�incref�decrefcCsxt|t�std�|t|����||_t�|�|_t	|\}}||dd�|_
|j
j|_ddi|_i|_
i|_t��|_dS)Nz&Authkey {0!r} is type {1!s}, not bytes�)r*Zbacklog�0�Nr)rG�bytesrIrJr�registryr�AuthenticationString�authkey�listener_client�listenerr*�	id_to_obj�id_to_refcount�id_to_local_proxy_obj�	threading�Lock�mutex)r,rdr*rf�
serializer�Listener�Clientrrrr-�s 
��

zServer.__init__c	Cs�t��|_|t��_zVtj|jd�}d|_|��z|j��sL|j�d�q4Wnttfk
rfYnXW5tjtjkr�t	�
d�tjt_tjt_t�
d�XdS)Nzresetting stdout, stderrr)�targetTr	)rl�Event�
stop_eventr�current_process�_manager_server�sys�stdout�
__stdout__r�debug�
__stderr__�stderr�exit�Thread�accepter�daemon�start�is_set�wait�KeyboardInterrupt�
SystemExit)r,rrrr�
serve_forever�s 




zServer.serve_forevercCsNz|j��}Wntk
r&YqYnXtj|j|fd�}d|_|��qdS)N�rrr?T)rhZaccept�OSErrorrlr~�handle_requestr�r�)r,r=�trrrr�s
zServer.acceptercCs4d}}}z>t�||j�t�||j�|��}|\}}}}t||�}Wntk
rhdt�f}	Yn>Xz||f|�|�}Wntk
r�dt�f}	Yn
Xd|f}	z|�|	�Wnrtk
�r&}
zRz|�dt�f�Wntk
r�YnXt	�
d|	�t	�
d|�t	�
d|
�W5d}
~
XYnX|��dS)NrEr9zFailure to send message: %rz ... request was %r� ... exception was %r)r
Zdeliver_challengerfZanswer_challenger;r�	Exceptionrr:r�info�close)r,r=�funcnamerB�request�ignorer?r@rR�msg�errrr��s2zServer.handle_requestc
Cs�t�dt��j�|j}|j}|j}|j�	��s�zBd}}|�}|\}}}	}
z||\}}}Wn^t
k
r�}
z@z|j|\}}}Wn&t
k
r�}z|
�W5d}~XYnXW5d}
~
XYnX||kr�td|t
|�|f��t||�}z||	|
�}Wn,tk
�r"}zd|f}W5d}~XYnPX|�o4|�|d�}|�rj|�|||�\}}t||j|�}d||ff}nd|f}Wn�tk
�r�|dk�r�dt�f}nNz,|j|}|||||f|	�|
�}d|f}Wn tk
�r�dt�f}YnXYnPtk
�rt�dt��j�t�d�Yn tk
�r<dt�f}YnXzDz||�Wn2tk
�r~}z|d	t�f�W5d}~XYnXWq$tk
�r�}z@t�d
t��j�t�d|�t�d|�|��t�d
�W5d}~XYq$Xq$dS)Nz$starting server thread to service %rz+method %r of %r object is not in exposed=%rrD�#PROXYr9rEz$got EOF -- exiting thread serving %rrrFzexception in thread serving %rz ... message was %rr�r	)rrzrl�current_threadrr;r:rirtr��KeyErrorrk�AttributeErrorrrr��getrXrr*r�fallback_mapping�EOFErrorrwr}r�r�)r,�connr;r:rir>r&r��identr?r@�exposed�	gettypeid�keZ	second_keZfunction�resr�r�r)ZridentZrexposed�tokenZ
fallback_funcrBrrr�serve_client�s���(��


����$�zServer.serve_clientcCs|Srr�r,r�r�r&rrr�fallback_getvalue5szServer.fallback_getvaluecCst|�Sr�rHr�rrr�fallback_str8szServer.fallback_strcCst|�Sr)�reprr�rrr�
fallback_repr;szServer.fallback_repr)rMr5�	#GETVALUEcCsdSrr�r,r=rrrr]DszServer.dummyc
Cs�|j�tg}t|j���}|��|D]<}|dkr&|�d||j|t|j|d�dd�f�q&d�|�W5QR�SQRXdS)Nraz  %s:       refcount=%s
    %sr�K�
)	rnr$rjr"�sortrPrHri�join)r,r=rBr"r�rrrr[Gs
��zServer.debug_infocCs
t|j�Sr)�lenrjr�rrrr\WszServer.number_of_objectscCsLz:zt�d�|�d�Wnddl}|��YnXW5|j��XdS)Nz!manager received shutdown message�r9Nr)rt�setrrzr:�	traceback�	print_exc)r,r=r�rrrrW^s
zServer.shutdownc	Os�t|�dkr|^}}}}n�|s(td��n�d|krDtdt|�d��|�d�}t|�dkr~|^}}}ddl}|jdtdd	�nFd
|kr�tdt|�d��|�d
�}|^}}ddl}|jdtdd	�t|�}|j��|j|\}}}}	|dk�r|�st|�dk�rt	d��|d}
n
|||�}
|dk�r2t
|
�}|dk	�rlt|t��s\td
�
|t|����t|�t|�}dt|
�}t�d||�|
t|�|f|j|<||jk�r�d|j|<W5QRX|�||�|t|�fS)N�z8descriptor 'create' of 'Server' object needs an argumentr)�7create expected at least 2 positional arguments, got %dr	�rz2Passing 'typeid' as keyword argument is deprecated)�
stacklevelr=z-Passing 'c' as keyword argument is deprecatedz4Without callable, must have one non-keyword argumentz,Method_to_typeid {0!r}: type {1!s}, not dictz%xz&%r callable returned object with id %r)r�rI�pop�warnings�warn�DeprecationWarning�tuplernrdrLrUrG�dictrJrr$r+rrzr�rirjr^)r?r@r,r=r)r�rOr��method_to_typeid�	proxytyper&r�rrrrXksp

�

�
�
��

�



��z
Server.createz$($self, c, typeid, /, *args, **kwds)cCst|j|jd�S)Nr	)r�rir+)r,r=r�rrrrZ�szServer.get_methodscCs"|t��_|�d�|�|�dS)Nr�)rlr�rr:r�)r,r=rrrrrY�s

zServer.accept_connectioncCs�|j��z|j|d7<Wnhtk
r�}zJ||jkrrd|j|<|j||j|<|j|\}}}t�d|�n|�W5d}~XYnXW5QRXdS)Nr	z&Server re-enabled tracking & INCREF %r)rnrjr�rkrirrz)r,r=r�r�r&r�r�rrrr^�s

�z
Server.increfc	Cs�||jkr$||jkr$t�d|�dS|j�Z|j|dkrXtd�||j||j|���|j|d8<|j|dkr�|j|=W5QRX||jkr�d|j|<t�d|�|j�|j|=W5QRXdS)NzServer DECREF skipping %rrz+Id {0!s} ({1!r}) has refcount {2:n}, not 1+r	)NrNzdisposing of obj with id %r)rjrkrrzrn�AssertionErrorrJri)r,r=r�rrrr_�s,
���

z
Server.decrefN)r4r6r7�publicr-r�rr�r�r�r�r�r�r]r[r\rWrX�__text_signature__rZrYr^r_rrrrrV�s:�
"Q�
=rVc@seZdZdgZdZdZdZdS)�State�valuerr	r�N)r4r6r7r8�INITIAL�STARTED�SHUTDOWNrrrrr��sr�)�pickleZ	xmlrpclibc@s�eZdZiZeZd!dd�Zdd�Zdd�Zd"d
d�Z	e
d#dd
��Zdd�Zd$dd�Z
dd�Zdd�Zdd�Zdd�Zedd��Zedd��Ze
d%dd ��ZdS)&rNr�cCs\|dkrt��j}||_t�|�|_t�|_tj|j_	||_
t|\|_|_
|pTt�|_dSr)rrurf�_addressre�_authkeyr��_stater�r��_serializerrgZ	_Listener�_Clientr�_ctx)r,r*rfroZctxrrrr-s

zBaseManager.__init__cCsf|jjtjkrP|jjtjkr&td��n*|jjtjkr>td��ntd�|jj���t|j	|j
|j|j�S)N�Already started server�Manager has shut down�Unknown state {!r})
r�r�r�r�r�r
r�rJrV�	_registryr�r�r�r.rrr�
get_servers

�
�zBaseManager.get_servercCs8t|j\}}||j|jd�}t|dd�tj|j_dS)N�rfr])	rgr�r�r�rCr�r�r�r�)r,rprqr�rrr�connectszBaseManager.connectrc	Cs4|jjtjkrP|jjtjkr&td��n*|jjtjkr>td��ntd�|jj���|dk	rht|�sht	d��t
jdd�\}}|jj
t|�j|j|j|j|j|||fd�|_d�d	d
�|jjD��}t|�jd||j_|j��|��|��|_|��tj|j_tj|t|�j|j|j|j|j|jfdd
�|_ dS)Nr�r�r�zinitializer must be a callableF)Zduplexr��:css|]}t|�VqdSrr�)r�irrr�	<genexpr>Asz$BaseManager.start.<locals>.<genexpr>�-r�r?Zexitpriority)!r�r�r�r�r�r
r�rJrOrIr
ZPiper�ZProcessr�_run_serverr�r�r�r��_processr�Z	_identityr4rr�r�r;r�Finalize�_finalize_managerr�rW)r,�initializer�initargs�reader�writerr�rrrr�(sH

���


��zBaseManager.startc	Cs^t�tjtj�|dk	r ||�|�||||�}|�|j�|��t�d|j�|�	�dS)Nzmanager serving at %r)
�signal�SIGINT�SIG_IGN�_Serverr:r*r�rr�r�)	�clsrdr*rfror�r�r��serverrrrr�SszBaseManager._run_servercOsN|j|j|jd�}zt|dd|f||�\}}W5|��Xt||j|�|fS)Nr�rX)r�r�r�r�rCr)r,r)r?r@r�r+r�rrr�_createjs

zBaseManager._createcCs*|jdk	r&|j�|�|j��s&d|_dSr)r�r��is_alive�r,�timeoutrrrr�vs

zBaseManager.joincCs2|j|j|jd�}zt|dd�W�S|��XdS)Nr�r[�r�r�r�r�rC�r,r�rrr�_debug_infoszBaseManager._debug_infocCs2|j|j|jd�}zt|dd�W�S|��XdS)Nr�r\r�r�rrr�_number_of_objects�szBaseManager._number_of_objectscCsj|jjtjkr|��|jjtjkrf|jjtjkr<td��n*|jjtjkrTtd��ntd�|jj���|S)NzUnable to start serverr�r�)	r�r�r�r�r�r�r
r�rJr.rrr�	__enter__�s

�zBaseManager.__enter__cCs|��dSr)rW�r,�exc_typeZexc_valZexc_tbrrr�__exit__�szBaseManager.__exit__cCs�|��r�t�d�z,|||d�}zt|dd�W5|��XWntk
rRYnX|jdd�|��r�t�d�t|d�r�t�d�|��|jd	d�|��r�t�d
�t	j
|_ztj
|=Wntk
r�YnXdS)Nz#sending shutdown message to managerr�rWg�?)r�zmanager still alive�	terminatez'trying to `terminate()` manager processg�������?z#manager still alive after terminate)r�rr�r�rCr�r��hasattrr�r�r�r�r�_address_to_localr�)rr*rfr1r�r�rrrr��s.




zBaseManager._finalize_managercCs|jSr)r�r.rrrr*�szBaseManager.addressTc
s�d|jkr|j��|_�dkr"t�|p0t�dd�}|p@t�dd�}|r\t|���D]\}}qR|||�f|j�<|r���fdd�}	�|	_t|�|	�dS)Nr��	_exposed_�_method_to_typeid_cs`t�d��|j�f|�|�\}}�||j||j|d�}|j|j|jd�}t|dd|jf�|S)Nz)requesting creation of a shared %r object��managerrfr�r�r_)	rrzr�r�r�r�r*rCr+)r,r?r@r�Zexp�proxyr��r�r)rrrQ�s�z"BaseManager.register.<locals>.temp)	�__dict__r��copy�	AutoProxyrr$r!r4�setattr)
r�r)rOr�r�r��
create_method�keyr�rQrr�r�register�s(

��

zBaseManager.register)NNr�N)Nr)Nr)N)NNNNT)r4r6r7r�rVr�r-r�r�r��classmethodr�r�r�r�r�r�r��staticmethodr��propertyr*rrrrrr�s6�
	
+�
	




�c@seZdZdd�Zdd�ZdS)�ProcessLocalSetcCst�|dd��dS)NcSs|��Sr)�clearr%rrr�<lambda>��z*ProcessLocalSet.__init__.<locals>.<lambda>)r�register_after_forkr.rrrr-�szProcessLocalSet.__init__cCst|�dfSrb)rr.rrr�
__reduce__�szProcessLocalSet.__reduce__N)r4r6r7r-r
rrrrr�src@s|eZdZiZe��Zddd�Zdd�Zdifd	d
�Z	dd�Z
d
d�Zedd��Z
dd�Zdd�Zdd�Zdd�Zdd�ZdS)rNTFc		Cs�tj�8tj�|jd�}|dkr:t��t�f}|tj|j<W5QRX|d|_|d|_	||_
|j
j|_||_
||_t|d|_||_|dk	r�t�|�|_n"|j
dk	r�|j
j|_nt��j|_|r�|��t�|tj�dS)Nrr	)r�_mutexr�r�r*rZForkAwareLocalr�_tls�_idset�_tokenr+�_id�_managerr�rgr��_owned_by_managerrrer�rurf�_increfr�_after_fork)	r,r�ror�rfr�r^�
manager_ownedZ	tls_idsetrrrr-s*



zBaseProxy.__init__cCsdt�d�t��j}t��jdkr4|dt��j7}|j|jj	|j
d�}t|dd|f�||j_
dS)Nzmaking connection to managerZ
MainThread�|r�rY)rrzrrurrlr�r�rr*r�rCrr
)r,rr�rrr�_connect-s

zBaseProxy._connectrcCs�z|jj}Wn6tk
rBt�dt��j�|��|jj}YnX|�	|j
|||f�|��\}}|dkrp|S|dkr�|\}}|jj
|jd}	|jj|_|	||j|j|j|d�}
|j|j|jd�}t|dd|jf�|
St||��dS)Nz#thread %r does not own a connectionr9r����r�r�r_)rr
r�rrzrlr�rrr:rr;rr�r)rr*r�r�r�rCr+r<)r,r>r?r@r�rArBr�r�r�r�rrr�_callmethod6s6�
�zBaseProxy._callmethodcCs
|�d�S)Nr��rr.rrr�	_getvalueTszBaseProxy._getvaluec	Cs�|jrt�d|jj�dS|j|jj|jd�}t|dd|j	f�t�d|jj�|j
�|j	�|joj|jj
}tj|tj|j|j||j|j
|jfdd�|_dS)Nz%owned_by_manager skipped INCREF of %rr�r^z	INCREF %r�
r�)rrrzrr+r�r*r�rCrr�addrr�r�r�_decrefrZ_close)r,r�r1rrrrZs$
��zBaseProxy._increfc
Cs�|�|j�|dks |jtjkr�z2t�d|j�||j|d�}t|dd|jf�Wq�t	k
r�}zt�d|�W5d}~XYq�Xnt�d|j�|s�t
|d�r�t�dt��j
�|j��|`dS)Nz	DECREF %rr�r_z... decref failed %sz%DECREF %r -- manager already shutdownr
z-thread %r has no more proxies so closing conn)�discardr+r�r�r�rrzr*rCr�r�rlr�rr
r�)r�rfr1ZtlsZidsetr�r�r�rrrr ns �
zBaseProxy._decrefc
CsHd|_z|��Wn0tk
rB}zt�d|�W5d}~XYnXdS)Nzincref failed: %s)rrr�rr�)r,r�rrrr�s
zBaseProxy._after_forkcCs^i}t�dk	r|j|d<t|dd�rB|j|d<tt|j|j|ffStt|�|j|j|ffSdS)Nrf�_isautoFr�)	rr�rr��RebuildProxyrrr�r�r,r@rrrr
�s


��zBaseProxy.__reduce__cCs|��Sr)r)r,Zmemorrr�__deepcopy__�szBaseProxy.__deepcopy__cCsdt|�j|jjt|�fS)Nz<%s object, typeid %r at %#x>)rr4rr)r+r.rrrr5�s�zBaseProxy.__repr__cCs:z|�d�WStk
r4t|�dd�dYSXdS)Nr5rz; '__str__()' failed>)rr�r�r.rrrrM�szBaseProxy.__str__)NNNTF)r4r6r7r�rZForkAwareThreadLockrr-rrrrrr rr
r%r5rMrrrrr�s&�
)	

cCs�tt��dd�}|rT|j|jkrTt�d|�d|d<|j|jkrT|j|j|j|j<|�	dd�optt��dd�}|||fd|i|��S)Nrvz*Rebuild a proxy owned by manager, token=%rTrr^Z_inheritingF)
rrrur*rrzr+rkrir�)rRr�ror@r�r^rrrr#�s
�
�r#cCspt|�}z|||fWStk
r*YnXi}|D]}td||f|�q4t|tf|�}||_||||f<|S)NzOdef %s(self, /, *args, **kwds):
        return self._callmethod(%r, args, kwds))r�r��execrrr�)rr��_cacheZdicZmeth�	ProxyTyperrr�
MakeProxyType�s ��r)c
Cs�t|d}|dkrB||j|d�}zt|dd|f�}W5|��X|dkrX|dk	rX|j}|dkrjt��j}td|j	|�}||||||d�}	d|	_
|	S)Nr	r�rZz
AutoProxy[%s])r�rfr^T)rgr*r�rCr�rrurfr)r)r")
r�ror�rfr�r^r�r�r(r�rrrr�s 


�rc@seZdZdd�Zdd�ZdS)�	NamespacecKs|j�|�dSr)r��updater$rrrr-�szNamespace.__init__cCsZt|j���}g}|D]$\}}|�d�s|�d||f�q|��d|jjd�|�fS)NrTz%s=%rz%s(%s)z, )	r$r�r!�
startswithrPr�r3r4r�)r,r!rQrr�rrrr5�s
zNamespace.__repr__N)r4r6r7r-r5rrrrr*�sr*c@s8eZdZddd�Zdd�Zdd�Zdd	�Zeee�Zd
S)�ValueTcCs||_||_dSr)�	_typecode�_value)r,rr��lockrrrr-szValue.__init__cCs|jSr�r/r.rrrr�sz	Value.getcCs
||_dSrr1�r,r�rrrr�
sz	Value.setcCsdt|�j|j|jfS)Nz
%s(%r, %r))rr4r.r/r.rrrr5szValue.__repr__N)T)	r4r6r7r-r�r�r5rr�rrrrr-s

r-cCst�||�Sr)r)r�sequencer0rrr�Arraysr4c@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�
IteratorProxy)�__next__r:�throwr�cCs|Srrr.rrr�__iter__szIteratorProxy.__iter__cGs|�d|�S)Nr6r�r,r?rrrr6szIteratorProxy.__next__cGs|�d|�S)Nr:rr9rrrr:szIteratorProxy.sendcGs|�d|�S)Nr7rr9rrrr7szIteratorProxy.throwcGs|�d|�S)Nr�rr9rrrr�!szIteratorProxy.closeN)	r4r6r7r�r8r6r:r7r�rrrrr5sr5c@s2eZdZdZddd�Zdd�Zdd	�Zd
d�ZdS)
�
AcquirerProxy)�acquire�releaseTNcCs"|dkr|fn||f}|�d|�S�Nr;r)r,Zblockingr�r?rrrr;'szAcquirerProxy.acquirecCs
|�d�S�Nr<rr.rrrr<*szAcquirerProxy.releasecCs
|�d�Sr=rr.rrrr�,szAcquirerProxy.__enter__cCs
|�d�Sr>rr�rrrr�.szAcquirerProxy.__exit__)TN)r4r6r7r�r;r<r�r�rrrrr:%s

r:c@s6eZdZdZddd�Zd
dd�Zdd	�Zdd
d�ZdS)�ConditionProxy)r;r<r��notify�
notify_allNcCs|�d|f�S�Nr�rr�rrrr�4szConditionProxy.waitr	cCs|�d|f�S)Nr@r)r,�nrrrr@6szConditionProxy.notifycCs
|�d�S)NrArr.rrrrA8szConditionProxy.notify_allcCsd|�}|r|S|dk	r$t��|}nd}d}|s`|dk	rN|t��}|dkrNq`|�|�|�}q,|S)Nr)�time�	monotonicr�)r,Z	predicater�rBZendtimeZwaittimerrr�wait_for:s
zConditionProxy.wait_for)N)r	)N)r4r6r7r�r�r@rArFrrrrr?2s


r?c@s2eZdZdZdd�Zdd�Zdd�Zdd	d
�ZdS)�
EventProxy)r�r�r	r�cCs
|�d�S)Nr�rr.rrrr�OszEventProxy.is_setcCs
|�d�S�Nr�rr.rrrr�QszEventProxy.setcCs
|�d�S)Nr	rr.rrrr	SszEventProxy.clearNcCs|�d|f�SrBrr�rrrr�UszEventProxy.wait)N)r4r6r7r�r�r�r	r�rrrrrGMs
rGc@sNeZdZdZddd�Zdd�Zdd�Zed	d
��Zedd��Z	ed
d��Z
dS)�BarrierProxy)�__getattribute__r��abort�resetNcCs|�d|f�SrBrr�rrrr�[szBarrierProxy.waitcCs
|�d�S)NrKrr.rrrrK]szBarrierProxy.abortcCs
|�d�S)NrLrr.rrrrL_szBarrierProxy.resetcCs|�dd�S)NrJ)�partiesrr.rrrrMaszBarrierProxy.partiescCs|�dd�S)NrJ)�	n_waitingrr.rrrrNdszBarrierProxy.n_waitingcCs|�dd�S)NrJ)�brokenrr.rrrrOgszBarrierProxy.broken)N)r4r6r7r�r�rKrLrrMrNrOrrrrrIYs


rIc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�NamespaceProxy)rJ�__setattr__�__delattr__cCs0|ddkrt�||�St�|d�}|d|f�S)NrrTrrJ)�objectrJ�r,r�
callmethodrrr�__getattr__nszNamespaceProxy.__getattr__cCs4|ddkrt�|||�St�|d�}|d||f�S)NrrTrrQ)rSrQrJ)r,rr�rUrrrrQsszNamespaceProxy.__setattr__cCs0|ddkrt�||�St�|d�}|d|f�S)NrrTrrR)rSrRrJrTrrrrRxszNamespaceProxy.__delattr__N)r4r6r7r�rVrQrRrrrrrPlsrPc@s*eZdZdZdd�Zdd�Zeee�ZdS)�
ValueProxy)r�r�cCs
|�d�S)Nr�rr.rrrr��szValueProxy.getcCs|�d|f�SrHrr2rrrr��szValueProxy.setN)r4r6r7r�r�r�rr�rrrrrWsrW�
BaseListProxy)�__add__�__contains__�__delitem__�__getitem__�__len__�__mul__�__reversed__�__rmul__�__setitem__rP�count�extend�index�insertr��remove�reverser��__imul__c@seZdZdd�Zdd�ZdS)�	ListProxycCs|�d|f�|S)Nrcrr2rrr�__iadd__�szListProxy.__iadd__cCs|�d|f�|S)Nrhrr2rrrrh�szListProxy.__imul__N)r4r6r7rjrhrrrrri�sri�	DictProxy)rZr[r\r8r]rar	r�r�r!r"r��popitem�
setdefaultr+r#r8�Iterator�
ArrayProxy)r]r\ra�	PoolProxy)Zapply�apply_asyncr��imap�imap_unorderedr��map�	map_async�starmap�
starmap_asyncr�ZAsyncResult)rqrurwrrrsc@seZdZdd�Zdd�ZdS)rpcCs|Srrr.rrrr��szPoolProxy.__enter__cCs|��dSr)r�r�rrrr��szPoolProxy.__exit__N)r4r6r7r�r�rrrrrp�sc@seZdZdS)rN)r4r6r7rrrrr�s�QueueZ
JoinableQueuersrm�RLock�	Semaphore�BoundedSemaphore�	Condition�Barrier�Poolr$r�)r�r)rc@sHeZdZgfdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�_SharedMemoryTrackercCs||_||_dSr�Zshared_memory_context_name�
segment_names)r,rr�rrrr-�sz_SharedMemoryTracker.__init__cCs(t�d|�dt����|j�|�dS)NzRegister segment � in pid )rrzrr�rP�r,�segment_namerrr�register_segment�sz%_SharedMemoryTracker.register_segmentcCsBt�d|�dt����|j�|�t�|�}|��|��dS)NzDestroy segment r�)	rrzrr�rfr�SharedMemoryr��unlink)r,r�Zsegmentrrr�destroy_segment�s

z$_SharedMemoryTracker.destroy_segmentcCs"|jdd�D]}|�|�qdSr)r�r�r�rrrr��sz_SharedMemoryTracker.unlinkcCs(t�d|jj�dt����|��dS)NzCall z.__del__ in )rrzr3r4rr�r.rrr�__del__�sz_SharedMemoryTracker.__del__cCs|j|jfSrr�r.rrrr/�sz!_SharedMemoryTracker.__getstate__cCs|j|�dSr)r-r0rrrr2sz!_SharedMemoryTracker.__setstate__N)
r4r6r7r-r�r�r�r�r/r2rrrrr�s	rc@sReZdZejdddgZdd�Zdd�Zde_d	d
�Zdd�Z	d
d�Z
dd�ZdS)�SharedMemoryServer�
track_segment�release_segment�
list_segmentscOsZtj|f|�|�|j}t|t�r,t�|�}td|�dt����|_	t
�dt����dS)NZshm_rTz"SharedMemoryServer started by pid )rVr-r*rGrc�os�fsdecoderr�shared_memory_contextrrz)r,r?�kwargsr*rrrr-
s

�zSharedMemoryServer.__init__cOstt|�dkr|d}n4d|kr(|d}n"|s6td��ntdt|�d��ttj|dd�rhtj|d	<tj||�S)
Nr�r�r)zDdescriptor 'create' of 'SharedMemoryServer' object needs an argumentr�r	rZ_shared_memory_proxyr�)r�rIr�r,rdr�rVrX)r?r�Ztypeodr)rrrrXs



�
zSharedMemoryServer.createz&($self, c, typeid, /, *args, **kwargs)cCs|j��t�||�Sr)r�r�rVrWr�rrrrW)s
zSharedMemoryServer.shutdowncCs|j�|�dSr)r�r��r,r=r�rrrr�.sz SharedMemoryServer.track_segmentcCs|j�|�dSr)r�r�r�rrrr�2sz"SharedMemoryServer.release_segmentcCs|jjSr)r�r�r�rrrr�7sz SharedMemoryServer.list_segmentsN)r4r6r7rVr�r-rXr�rWr�r�r�rrrrr�s�
r�c@s8eZdZeZdd�Zdd�Zdd�Zdd�Zd	d
�Z	dS)rcOsNtjdkrddlm}|��tj|f|�|�t�|j	j
�dt����dS)N�posixr	)�resource_trackerz created by pid )r�r�r�Zensure_runningrr-rrzr3r4r)r,r?r�r�rrrr-Is

zSharedMemoryManager.__init__cCst�|jj�dt����dS)Nz.__del__ by pid )rrzr3r4rr.rrrr�UszSharedMemoryManager.__del__cCsh|jjtjkrP|jjtjkr&td��n*|jjtjkr>td��ntd�|jj���|�|j	|j
|j|j�S)Nz"Already started SharedMemoryServerz!SharedMemoryManager has shut downr�)
r�r�r�r�r�r
r�rJr�r�r�r�r�r.rrrr�Ys

��zSharedMemoryManager.get_servercCsx|j|j|jd��\}tjdd|d�}zt|dd|jf�Wn.tk
rh}z|��|�W5d}~XYnXW5QRX|S)Nr�T)rX�sizer�)	r�r�r�rr�rCr�
BaseExceptionr�)r,r�r�Zsmsr�rrrr�fs z SharedMemoryManager.SharedMemorycCsv|j|j|jd��Z}t�|�}zt|dd|jjf�Wn0tk
rf}z|j�	�|�W5d}~XYnXW5QRX|S)Nr�r�)
r�r�r�r�
ShareableListrCZshmrr�r�)r,r3r�Zslr�rrrr�rs

 z!SharedMemoryManager.ShareableListN)
r4r6r7r�r�r-r�r�r�r�rrrrr=s

)NNNT)T)S�__all__rwrlr�rZqueuerDr�rr�rr�r
�contextrrr
rrrrrZ	HAS_SHMEM�ImportErrorrrZ
view_typesr$r'Z	view_typerSrrCr<r�rKrSrUrVr�rprqZXmlListenerZ	XmlClientrgrr�rrr#r)rr*r-r4r5r:r?rGrIrPrWrXrirkr�roZ
BasePoolProxyrprrxrsrmryrzr{r|r}r~r�rr�rrrrr�<module>s��


c

�	w
4�


	
	
�

�

�%8