Hacked By AnonymousFox

Current Path : /opt/alt/python39/lib64/python3.9/multiprocessing/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/multiprocessing/__pycache__/managers.cpython-39.opt-1.pyc

a

R�fǸ�@sLgd�ZddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZddlm
Z
ddlmZmZmZddlmZdd	lmZdd
lmZddlmZzddlmZWney�d
ZYn0dZe�d�dd�Ze�eje�dd�dD�Zedeu�r8dd�ZeD]Ze�ee��q$Gdd�de �Z!difdd�Z"dd�Z#Gdd�de$�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*�d*e �Z/Gd+d,�d,e0�Z1Gd-d.�d.e �Z2d/d0�Z3ifd1d2�Z4dmd3d4�Z5Gd5d6�d6e �Z6Gd7d8�d8e �Z7dnd9d:�Z8Gd;d<�d<e2�Z9Gd=d>�d>e2�Z:Gd?d@�d@e:�Z;GdAdB�dBe2�Z<GdCdD�dDe2�Z=GdEdF�dFe2�Z>GdGdH�dHe2�Z?e4dIdJ�Z@GdKdL�dLe@�ZAe4dMdN�ZBdOdPieB_Ce4dQdR�ZDe4dSdT�ZEdUdUdUdPdPdV�eE_CGdWdS�dSeE�ZFGdXdY�dYe/�ZGeG�dZejH�eG�d[ejH�eG�d\ejIe<�eG�d]ejJe:�eG�d^ejKe:�eG�d_ejLe:�eG�d`ejMe:�eG�daejNe;�eG�dbejOe=�eG�dcejPeF�eG�ddeeA�eG�deeQeB�eG�d8e7e?�eG�d:e8eD�eG�d6e6e>�eGjdPe9d
df�eGjdUd
dg�e�rHGdhdi�di�ZRGdjdk�dke(�ZSGdld�de/�ZTdS)o)�BaseManager�SyncManager�	BaseProxy�Token�N)�getpid)�
format_exc�)�
connection)�	reduction�get_spawning_popen�ProcessError)�pool)�process)�util)�get_context)�
shared_memoryFT�SharedMemoryManagercCstj|j|��ffS�N)�array�typecode�tobytes)�a�r�=/opt/alt/python39/lib64/python3.9/multiprocessing/managers.py�reduce_array/srcCsg|]}tti|����qSr)�type�getattr��.0�namerrr�
<listcomp>3�r )�items�keys�valuescCstt|�ffSr)�list��objrrr�rebuild_as_list5sr(c@s4eZdZdZdZdd�Zdd�Zdd�Zd	d
�ZdS)rz3
    Type to uniquely identify a shared object
    ��typeid�address�idcCs||||_|_|_dSrr))�selfr*r+r,rrr�__init__DszToken.__init__cCs|j|j|jfSrr)�r-rrr�__getstate__GszToken.__getstate__cCs|\|_|_|_dSrr)�r-�staterrr�__setstate__JszToken.__setstate__cCsd|jj|j|j|jfS)Nz %s(typeid=%r, address=%r, id=%r))�	__class__�__name__r*r+r,r/rrr�__repr__Ms�zToken.__repr__N)	r5�
__module__�__qualname__�__doc__�	__slots__r.r0r3r6rrrrr>srrcCs8|�||||f�|��\}}|dkr*|St||��dS)zL
    Send a message to manager using connection `c` and return response
    �#RETURNN)�send�recv�convert_to_error)�cr,�
methodname�args�kwds�kind�resultrrr�dispatchUs
rEcCsd|dkr|S|dvrRt|t�s4td�||t|����|dkrHtd|�St|�Sntd�|��SdS)N�#ERROR)�
#TRACEBACK�#UNSERIALIZABLEz.Result {0!r} (kind '{1}') type is {2}, not strrHzUnserializable message: %s
zUnrecognized message type {!r})�
isinstance�str�	TypeError�formatr�RemoteError�
ValueError)rCrDrrrr>_s

��
r>c@seZdZdd�ZdS)rMcCsdt|jd�dS)NzM
---------------------------------------------------------------------------
rzK---------------------------------------------------------------------------)rJrAr/rrr�__str__oszRemoteError.__str__N)r5r7r8rOrrrrrMnsrMcCs2g}t|�D] }t||�}t|�r|�|�q|S)z4
    Return a list of names of methods of `obj`
    )�dirr�callable�append)r'�tempr�funcrrr�all_methodsvs
rUcCsdd�t|�D�S)zP
    Return a list of names of methods of `obj` which do not start with '_'
    cSsg|]}|ddkr|�qS)r�_rrrrrr �r!z"public_methods.<locals>.<listcomp>)rUr&rrr�public_methods�srWc@s�eZdZdZgd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zeee
d�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&S)'�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�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)rI�bytesrKrLr�registryr�AuthenticationString�authkey�listener_client�listenerr+�	id_to_obj�id_to_refcount�id_to_local_proxy_obj�	threading�Lock�mutex)r-rfr+rh�
serializer�Listener�Clientrrrr.�s
��

zServer.__init__c	Cs�t��|_|t��_z�tj|jd�}d|_|�	�z|j�
�sL|j�d�q4Wntt
fydYn0Wtjtjkr�t�d�tjt_tjt_t�d�n2tjtjkr�t�d�tjt_tjt_t�d�0dS)z(
        Run the server forever
        )�targetTrzresetting stdout, stderrrN)rn�Event�
stop_eventr�current_process�_manager_server�Thread�accepter�daemon�start�is_set�wait�KeyboardInterrupt�
SystemExit�sys�stdout�
__stdout__r�debug�
__stderr__�stderr�exit)r-rzrrr�
serve_forever�s*



�
zServer.serve_forevercCsLz|j��}Wnty$YqYn0tj|j|fd�}d|_|��qdS)N�rtrAT)rjZaccept�OSErrorrnry�handle_requestr{r|)r-r?�trrrrz�s
zServer.acceptercCs6d}}}z>t�||j�t�||j�|��}|\}}}}t||�}Wntyfdt�f}	YnB0z||g|�Ri|��}Wnty�dt�f}	Yn
0d|f}	z|�|	�Wnrt�y(}
zXz|�dt�f�Wnty�Yn0t	�
d|	�t	�
d|�t	�
d|
�WYd}
~
n
d}
~
00|��dS)z)
        Handle a new connection
        NrGr;zFailure to send message: %rz ... request was %r� ... exception was %r)r	Zdeliver_challengerhZanswer_challenger=r�	Exceptionrr<r�info�close)r-r?�funcnamerD�request�ignorerArBrT�msg�errrr��s2"zServer.handle_requestcCs�t�dt��j�|j}|j}|j}|j�	��sΐz:d}}|�}|\}}}	}
z||\}}}WnPt
y�}
z8z|j|\}}}Wnt
y�|
�Yn0WYd}
~
n
d}
~
00||vr�td|t
|�|f��t||�}z||	i|
��}Wn.t�y}zd|f}WYd}~nXd}~00|�o,|�|d�}|�rb|�|||�\}}t||j|�}d||ff}nd|f}Wn�t�y�|du�r�dt�f}nRz2|j|}|||||g|	�Ri|
��}d|f}Wnt�y�dt�f}Yn0YnLt�yt�dt��j�t�d	�Ynt�y2dt�f}Yn0z4z||�Wn"t�yd|d
t�f�Yn0Wq$t�y�}zHt�dt��j�t�d|�t�d
|�|��t�d�WYd}~q$d}~00q$dS)zQ
        Handle requests from the proxies in a particular process/thread
        z$starting server thread to service %rNz+method %r of %r object is not in exposed=%rrF�#PROXYr;rGz$got EOF -- exiting thread serving %rrrHzexception in thread serving %rz ... message was %rr�r)rr�rn�current_threadrr=r<rkrvr}�KeyErrorrm�AttributeErrorrrr��getrZrr+r�fallback_mapping�EOFErrorr�r�r�r�)r-�connr=r<rkr@r'r��identrArB�exposed�	gettypeid�keZfunction�resr�r�r*ZridentZrexposed�tokenZ
fallback_funcrDrrr�serve_client�s��� ��


�����zServer.serve_clientcCs|Srr�r-r�r�r'rrr�fallback_getvalue7szServer.fallback_getvaluecCst|�Sr�rJr�rrr�fallback_str:szServer.fallback_strcCst|�Sr)�reprr�rrr�
fallback_repr=szServer.fallback_repr)rOr6�	#GETVALUEcCsdSrr�r-r?rrrr_FszServer.dummyc
Cs�|j�vg}t|j���}|��|D]<}|dkr&|�d||j|t|j|d�dd�f�q&d�|�Wd�S1s�0YdS)zO
        Return some info --- useful to spot problems with refcounting
        rcz  %s:       refcount=%s
    %srN�K�
)	rpr%rlr#�sortrRrJrk�join)r-r?rDr#r�rrrr]Is
��zServer.debug_infocCs
t|j�S)z*
        Number of shared objects
        )�lenrlr�rrrr^YszServer.number_of_objectscCsVzDzt�d�|�d�Wnddl}|��Yn0W|j��n|j��0dS)z'
        Shutdown this process
        z!manager received shutdown message�r;NrN)rr�r<�	traceback�	print_excrv�set)r-r?r�rrrrY`s
zServer.shutdowncOs|j��|j|\}}}}|durD|s2t|�dkr:td��|d}	n||i|��}	|durbt|	�}|dur�t|t�s�td�|t	|����t
|�t
|�}dt|	�}
t�
d||
�|	t|�|f|j|
<|
|jvr�d|j|
<Wd�n1s�0Y|�||
�|
t|�fS)z>
        Create a new shared object and return its id
        Nrz4Without 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)rprfr�rNrWrI�dictrKrLrr%r,rr�r�rkrlr`�tuple)r-r?r*rArBrQr��method_to_typeid�	proxytyper'r�rrrrZms6�
�

��
(z
Server.createcCst|j|jd�S)zL
        Return the methods of the shared object indicated by token
        r)r�rkr,)r-r?r�rrrr\�szServer.get_methodscCs"|t��_|�d�|�|�dS)z=
        Spawn a new thread to serve this connection
        r�N)rnr�rr<r�)r-r?rrrrr[�s

zServer.accept_connectioncCs�|j��z|j|d7<Wnjty�}zR||jvrpd|j|<|j||j|<|j|\}}}t�d|�n|�WYd}~n
d}~00Wd�n1s�0YdS)Nrz&Server re-enabled tracking & INCREF %r)rprlr�rmrkrr�)r-r?r�r�r'r�r�rrrr`�s

�z
Server.increfcCs�||jvr$||jvr$t�d|�dS|j�d|j|dkrXtd�||j||j|���|j|d8<|j|dkr�|j|=Wd�n1s�0Y||jvr�d|j|<t�d|�|j�|j|=Wd�n1s�0YdS)NzServer DECREF skipping %rrz+Id {0!s} ({1!r}) has refcount {2:n}, not 1+r)NrNzdisposing of obj with id %r)rlrmrr�rp�AssertionErrorrLrk)r-r?r�rrrra�s*
�
��&

z
Server.decrefN)r5r7r8r9�publicr.r�rzr�r�r�r�r�r�r_r]r^rYrZr\r[r`rarrrrrX�s.
"Q�
$rXc@seZdZdgZdZdZdZdS)�State�valuerr�N)r5r7r8r:�INITIAL�STARTED�SHUTDOWNrrrrr��sr�)�pickleZ	xmlrpclibc@s�eZdZdZiZeZd"dd�Zdd�Zdd	�Z	d#dd�Z
ed$d
d��Zdd�Z
d%dd�Zdd�Zdd�Zdd�Zdd�Zedd��Zedd��Zed&d d!��ZdS)'rz!
    Base class for managers
    Nr�cCs\|durt��j}||_t�|�|_t�|_tj|j_	||_
t|\|_|_
|pTt�|_dSr)rrwrh�_addressrg�_authkeyr��_stater�r��_serializerriZ	_Listener�_Clientr�_ctx)r-r+rhrq�ctxrrrr.�s

zBaseManager.__init__cCsf|jjtjkrP|jjtjkr&td��n*|jjtjkr>td��ntd�|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�rLrX�	_registryr�r�r�r/rrr�
get_server�s

�
�zBaseManager.get_servercCs8t|j\}}||j|jd�}t|dd�tj|j_dS)z>
        Connect manager object to the server process
        �rhNr_)	rir�r�r�rEr�r�r�r�)r-rrrsr�rrr�connectszBaseManager.connectrc	Cs4|jjtjkrP|jjtjkr&td��n*|jjtjkr>td��ntd�|jj���|durht|�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)z@
        Spawn a server process for this manager object
        r�r�r�Nzinitializer must be a callableF)Zduplexr��:css|]}t|�VqdSrr�)r�irrr�	<genexpr>(r!z$BaseManager.start.<locals>.<genexpr>�-r�rAZexitpriority)!r�r�r�r�r�rr�rLrQrKr	ZPiper�ZProcessr�_run_serverr�r�r�r��_processr�Z	_identityr5rr|r�r=r�Finalize�_finalize_managerr�rY)r-�initializer�initargs�reader�writerr�rrrr|s>

�
��



��zBaseManager.startc	Cs^t�tjtj�|dur ||�|�||||�}|�|j�|��t�d|j�|�	�dS)z@
        Create a server, report its address and run it
        Nzmanager serving at %r)
�signal�SIGINT�SIG_IGN�_Serverr<r+r�rr�r�)	�clsrfr+rhrqr�r�r��serverrrrr�:szBaseManager._run_servercOsV|j|j|jd�}z&t|dd|f||�\}}W|��n
|��0t||j|�|fS)zP
        Create a new shared object; return the token and exposed tuple
        r�NrZ)r�r�r�rEr�r)r-r*rArBr�r,r�rrr�_createQs
zBaseManager._createcCs*|jdur&|j�|�|j��s&d|_dS)zC
        Join the manager process (if it has been spawned)
        N)r�r��is_alive�r-�timeoutrrrr�]s

zBaseManager.joincCs8|j|j|jd�}zt|dd�W|��S|��0dS)zS
        Return some info about the servers shared objects and connections
        r�Nr]�r�r�r�rEr��r-r�rrr�_debug_infofs�zBaseManager._debug_infocCs8|j|j|jd�}zt|dd�W|��S|��0dS)z5
        Return the number of shared objects
        r�Nr^r�r�rrr�_number_of_objectsps�zBaseManager._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�rLr/rrr�	__enter__zs

�zBaseManager.__enter__cCs|��dSr)rY�r-�exc_typeZexc_valZexc_tbrrr�__exit__�szBaseManager.__exit__cCs�|��r�t�d�z4|||d�}zt|dd�W|��n
|��0WntyXYn0|jdd�|��r�t�d�t|d�r�t�d	�|��|jdd�|��r�t�d
�t	j
|_ztj
|=Wnty�Yn0dS)zQ
        Shutdown the manager process; will be registered as a finalizer
        z#sending shutdown message to managerr�NrYg�?)r�zmanager still alive�	terminatez'trying to `terminate()` manager processz#manager still alive after terminate)r�rr�rEr�r�r��hasattrr�r�r�r�r�_address_to_localr�)rr+rhr2r�r�rrrr��s.




zBaseManager._finalize_managercCs|jSr)r�r/rrrr+�szBaseManager.addressTc
s�d|jvr|j��|_�dur"t�|p0t�dd�}|p@t�dd�}|r\t|���D]\}}qR|||�f|j�<|r���fdd�}	�|	_t|�|	�dS)z9
        Register a typeid with the manager type
        r�N�	_exposed_�_method_to_typeid_csft�d��|j�g|�Ri|��\}}�||j||j|d�}|j|j|jd�}t|dd|jf�|S)Nz)requesting creation of a shared %r object��managerrhr�r�ra)	rr�r�r�r�r�r+rEr,)r-rArBr�Zexp�proxyr��r�r*rrrS�s�z"BaseManager.register.<locals>.temp)	�__dict__r��copy�	AutoProxyrr%r"r5�setattr)
r�r*rQr�r�r��
create_method�keyr�rSrr�r�register�s"

��

zBaseManager.register)NNr�N)Nr)Nr)N)NNNNT)r5r7r8r9r�rXr�r.r�r�r|�classmethodr�r�r�r�r�r�r��staticmethodr��propertyr+r�rrrrr�s4�
	
+�
	




�rc@seZdZdd�Zdd�ZdS)�ProcessLocalSetcCst�|dd��dS)NcSs|��Sr)�clearr&rrr�<lambda>�r!z*ProcessLocalSet.__init__.<locals>.<lambda>)r�register_after_forkr/rrrr.�szProcessLocalSet.__init__cCst|�dfSrd)rr/rrr�
__reduce__�szProcessLocalSet.__reduce__N)r5r7r8r.rrrrrr�src@s�eZdZdZiZe��Zddd�Zdd�Z	d	ifd
d�Z
dd
�Zdd�Ze
dd��Zdd�Zdd�Zdd�Zdd�Zdd�ZdS)rz.
    A base for proxies of shared objects
    NTFc	Cs�tj�Btj�|jd�}|dur:t��t�f}|tj|j<Wd�n1sN0Y|d|_|d|_	||_
|j
j|_||_
||_t|d|_||_|dur�t�|�|_n"|j
dur�|j
j|_nt��j|_|r�|��t�|tj�dS)Nrr)r�_mutexr�r�r+rZForkAwareLocalr�_tls�_idset�_tokenr,�_id�_managerr�rir��_owned_by_managerrrgr�rwrh�_increfr�_after_fork)	r-r�rqr�rhr�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�r[)rr�rrwrrnr�r�rr+r�rEr	r	)r-rr�rrr�_connects

zBaseProxy._connectrcCs�z|jj}Wn4ty@t�dt��j�|��|jj}Yn0|�	|j
|||f�|��\}}|dkrn|S|dkr�|\}}|jj
|jd}	|jj|_|	||j|j|j|d�}
|j|j|jd�}t|dd|jf�|
St||��dS)	zV
        Try to call a method of the referent and return a copy of the result
        z#thread %r does not own a connectionr;r����r�r�Nra)r	r	r�rr�rnr�rrr<rr=r
r�r*rr+r�r�r�rEr,r>)r-r@rArBr�rCrDr�r�r�r�rrr�_callmethods0�

�zBaseProxy._callmethodcCs
|�d�S)z9
        Get a copy of the value of the referent
        r��rr/rrr�	_getvalue;szBaseProxy._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�)rrr�rr,r�r+r�rErr
�addr
r�r�r�_decrefr	Z_close)r-r�r2rrrrAs
��zBaseProxy._increfc
Cs�|�|j�|dus |jtjkr�z2t�d|j�||j|d�}t|dd|jf�Wq�t	y�}zt�d|�WYd}~q�d}~00nt�d|j�|s�t
|d�r�t�dt��j
�|j��|`dS)Nz	DECREF %rr�raz... decref failed %sz%DECREF %r -- manager already shutdownr	z-thread %r has no more proxies so closing conn)�discardr,r�r�r�rr�r+rEr�r�rnr�rr	r�)r�rhr2ZtlsZidsetr�r�r�rrrrUs$�
zBaseProxy._decrefc
CsJd|_z|��Wn2tyD}zt�d|�WYd}~n
d}~00dS)Nzincref failed: %s)r
rr�rr�)r-r�rrrrns
zBaseProxy._after_forkcCs^i}t�dur|j|d<t|dd�rB|j|d<tt|j|j|ffStt|�|j|j|ffSdS)Nrh�_isautoFr�)	rr�rr��RebuildProxyr�rr�r�r-rBrrrrvs


��zBaseProxy.__reduce__cCs|��Sr)r)r-�memorrr�__deepcopy__�szBaseProxy.__deepcopy__cCsdt|�j|jjt|�fS)Nz<%s object, typeid %r at %#x>)rr5rr*r,r/rrrr6�s�zBaseProxy.__repr__cCs8z|�d�WSty2t|�dd�dYS0dS)zV
        Return representation of the referent (or a fall-back if that fails)
        r6Nrz; '__str__()' failed>)rr�r�r/rrrrO�szBaseProxy.__str__)NNNTF)r5r7r8r9r�rZForkAwareThreadLockrr.rrrrrrrrr r6rOrrrrr�s"�
)	

rcCs�tt��dd�}|rT|j|jkrTt�d|�d|d<|j|jvrT|j|j|j|j<|�	dd�optt��dd�}|||fd|i|��S)	z5
    Function used for unpickling proxy objects.
    rxNz*Rebuild a proxy owned by manager, token=%rTrr`Z_inheritingF)
rrrwr+rr�r,rmrk�pop)rTr�rqrBr�r`rrrr�s
�
�rcCsnt|�}z|||fWSty(Yn0i}|D]}td||f|�q2t|tf|�}||_||||f<|S)zB
    Return a proxy type whose methods are given by `exposed`
    zOdef %s(self, /, *args, **kwds):
        return self._callmethod(%r, args, kwds))r�r��execrrr�)rr��_cacheZdicZmeth�	ProxyTyperrr�
MakeProxyType�s ��r%cCs�t|d}|durJ||j|d�}zt|dd|f�}W|��n
|��0|dur`|dur`|j}|durrt��j}td|j	|�}	|	||||||d�}
d|
_
|
S)z*
    Return an auto-proxy for `token`
    rNr�r\z
AutoProxy[%s])r�rhr`rT)rir+rEr�r�rrwrhr%r*r)r�rqr�rhr�r`rr�r�r$r�rrrr��s 

�r�c@seZdZdd�Zdd�ZdS)�	NamespacecKs|j�|�dSr)r��updaterrrrr.�szNamespace.__init__cCsZt|j���}g}|D]$\}}|�d�s|�d||f�q|��d|jjd�|�fS)NrVz%s=%rz%s(%s)z, )	r%r�r"�
startswithrRr�r4r5r�)r-r"rSrr�rrrr6�s
zNamespace.__repr__N)r5r7r8r.r6rrrrr&�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
||_dSrr-�r-r�rrrr��sz	Value.setcCsdt|�j|j|jfS)Nz
%s(%r, %r))rr5r*r+r/rrrr6�szValue.__repr__N)T)	r5r7r8r.r�r�r6rr�rrrrr)�s

r)cCst�||�Sr)r)r�sequencer,rrr�Array�sr0c@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�
IteratorProxy)�__next__r<�throwr�cCs|Srrr/rrr�__iter__szIteratorProxy.__iter__cGs|�d|�S)Nr2r�r-rArrrr2szIteratorProxy.__next__cGs|�d|�S)Nr<rr5rrrr<szIteratorProxy.sendcGs|�d|�S)Nr3rr5rrrr3szIteratorProxy.throwcGs|�d|�S)Nr�rr5rrrr�szIteratorProxy.closeN)	r5r7r8r�r4r2r<r3r�rrrrr1�sr1c@s2eZdZdZddd�Zdd�Zdd	�Zd
d�ZdS)
�
AcquirerProxy)�acquire�releaseTNcCs"|dur|fn||f}|�d|�S�Nr7r)r-Zblockingr�rArrrr7szAcquirerProxy.acquirecCs
|�d�S�Nr8rr/rrrr8szAcquirerProxy.releasecCs
|�d�Sr9rr/rrrr�szAcquirerProxy.__enter__cCs
|�d�Sr:rr�rrrr�szAcquirerProxy.__exit__)TN)r5r7r8r�r7r8r�r�rrrrr6s

r6c@s6eZdZdZddd�Zd
dd�Zdd	�Zdd
d�ZdS)�ConditionProxy)r7r8r~�notify�
notify_allNcCs|�d|f�S�Nr~rr�rrrr~szConditionProxy.waitrcCs|�d|f�S)Nr<r)r-�nrrrr<szConditionProxy.notifycCs
|�d�S)Nr=rr/rrrr=szConditionProxy.notify_allcCsd|�}|r|S|dur$t��|}nd}d}|s`|durN|t��}|dkrNq`|�|�|�}q,|S)Nr)�time�	monotonicr~)r-Z	predicater�rDZendtimeZwaittimerrr�wait_for!s
zConditionProxy.wait_for)N)r)N)r5r7r8r�r~r<r=rBrrrrr;s


r;c@s2eZdZdZdd�Zdd�Zdd�Zdd	d
�ZdS)�
EventProxy)r}r�rr~cCs
|�d�S)Nr}rr/rrrr}6szEventProxy.is_setcCs
|�d�S�Nr�rr/rrrr�8szEventProxy.setcCs
|�d�S)Nrrr/rrrr:szEventProxy.clearNcCs|�d|f�Sr>rr�rrrr~<szEventProxy.wait)N)r5r7r8r�r}r�rr~rrrrrC4s
rCc@sNeZdZdZddd�Zdd�Zdd�Zed	d
��Zedd��Z	ed
d��Z
dS)�BarrierProxy)�__getattribute__r~�abort�resetNcCs|�d|f�Sr>rr�rrrr~BszBarrierProxy.waitcCs
|�d�S)NrGrr/rrrrGDszBarrierProxy.abortcCs
|�d�S)NrHrr/rrrrHFszBarrierProxy.resetcCs|�dd�S)NrF)�partiesrr/rrrrIHszBarrierProxy.partiescCs|�dd�S)NrF)�	n_waitingrr/rrrrJKszBarrierProxy.n_waitingcCs|�dd�S)NrF)�brokenrr/rrrrKNszBarrierProxy.broken)N)r5r7r8r�r~rGrHrrIrJrKrrrrrE@s


rEc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�NamespaceProxy)rF�__setattr__�__delattr__cCs0|ddkrt�||�St�|d�}|d|f�S)NrrVrrF)�objectrF�r-r��
callmethodrrr�__getattr__UszNamespaceProxy.__getattr__cCs4|ddkrt�|||�St�|d�}|d||f�S)NrrVrrM)rOrMrF)r-r�r�rQrrrrMZszNamespaceProxy.__setattr__cCs0|ddkrt�||�St�|d�}|d|f�S)NrrVrrN)rOrNrFrPrrrrN_szNamespaceProxy.__delattr__N)r5r7r8r�rRrMrNrrrrrLSsrLc@s4eZdZdZdd�Zdd�Zeee�Zee	j
�ZdS)�
ValueProxy)r�r�cCs
|�d�S)Nr�rr/rrrr�hszValueProxy.getcCs|�d|f�SrDrr.rrrr�jszValueProxy.setN)r5r7r8r�r�r�rr�r�types�GenericAlias�__class_getitem__rrrrrSfs

rS�
BaseListProxy)�__add__�__contains__�__delitem__�__getitem__�__len__�__mul__�__reversed__�__rmul__�__setitem__rR�count�extend�index�insertr!�remove�reverser��__imul__c@seZdZdd�Zdd�ZdS)�	ListProxycCs|�d|f�|S)Nrbrr.rrr�__iadd__xszListProxy.__iadd__cCs|�d|f�|S)Nrgrr.rrrrg{szListProxy.__imul__N)r5r7r8rirgrrrrrhwsrh�	DictProxy)rYrZr[r4r\r`rr�r�r"r#r!�popitem�
setdefaultr'r$r4�Iterator�
ArrayProxy)r\r[r`�	PoolProxy)Zapply�apply_asyncr��imap�imap_unorderedr��map�	map_async�starmap�
starmap_asyncr�ZAsyncResult)rprtrvrqrrc@seZdZdd�Zdd�ZdS)rocCs|Srrr/rrrr��szPoolProxy.__enter__cCs|��dSr)r�r�rrrr��szPoolProxy.__exit__N)r5r7r8r�r�rrrrro�sc@seZdZdZdS)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)r5r7r8r9rrrrr�sr�QueueZ
JoinableQueueruro�RLock�	Semaphore�BoundedSemaphore�	Condition�Barrier�Poolr%r�)r�r�)r�c@sLeZdZdZgfdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�_SharedMemoryTrackerz+Manages one or more shared memory segments.cCs||_||_dSr�Zshared_memory_context_name�
segment_names)r-rr�rrrr.�sz_SharedMemoryTracker.__init__cCs(t�d|�dt����|j�|�dS)z6Adds the supplied shared memory block name to tracker.zRegister segment � in pid N)rr�rr�rR�r-�segment_namerrr�register_segment�sz%_SharedMemoryTracker.register_segmentcCsBt�d|�dt����|j�|�t�|�}|��|��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 r�N)	rr�rr�rer�SharedMemoryr��unlink)r-r�Zsegmentrrr�destroy_segment�s

z$_SharedMemoryTracker.destroy_segmentcCs"|jdd�D]}|�|�qdS)z<Calls destroy_segment() on all tracked shared memory blocks.N)r�r�r�rrrr��sz_SharedMemoryTracker.unlinkcCs(t�d|jj�dt����|��dS)NzCall z.__del__ in )rr�r4r5rr�r/rrr�__del__�sz_SharedMemoryTracker.__del__cCs|j|jfSrrr/rrrr0�sz!_SharedMemoryTracker.__getstate__cCs|j|�dSr)r.r1rrrr3�sz!_SharedMemoryTracker.__setstate__N)r5r7r8r9r.r�r�r�r�r0r3rrrrr~�s	r~c@sJeZdZejgd�Zdd�Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dS)�SharedMemoryServer)�
track_segment�release_segment�
list_segmentscOs`tj|g|�Ri|��|j}t|t�r2t�|�}td|�dt����|_	t
�dt����dS)NZshm_rVz"SharedMemoryServer started by pid )rXr.r+rIre�os�fsdecoder~r�shared_memory_contextrr�)r-rA�kwargsr+rrrr.�s

�zSharedMemoryServer.__init__cOs: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.rZ_shared_memory_proxyr�)r�rfr�rXrZ)r-r?r*rAr�rrrrZ�s
zSharedMemoryServer.createcCs|j��t�||�S)zACall unlink() on all tracked shared memory, terminate the Server.)r�r�rXrYr�rrrrYs
zSharedMemoryServer.shutdowncCs|j�|�dS)z?Adds the supplied shared memory block name to Server's tracker.N)r�r��r-r?r�rrrr�sz SharedMemoryServer.track_segmentcCs|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)r�r�r�rrrr�sz"SharedMemoryServer.release_segmentcCs|jjS)zbReturns a list of names of shared memory blocks that the Server
            is currently tracking.)r�r�r�rrrr�sz SharedMemoryServer.list_segmentsN)r5r7r8rXr�r.rZrYr�r�r�rrrrr��s�

r�c@s<eZdZdZeZdd�Zdd�Zdd�Zdd	�Z	d
d�Z
dS)
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).
        cOsTtjdkrddlm}|��tj|g|�Ri|��t�|j	j
�dt����dS)N�posixr)�resource_trackerz created by pid )r�r�r�Zensure_runningrr.rr�r4r5r)r-rAr�r�rrrr.'s

zSharedMemoryManager.__init__cCst�|jj�dt����dS)Nz.__del__ by pid )rr�r4r5rr/rrrr�3szSharedMemoryManager.__del__cCsh|jjtjkrP|jjtjkr&td��n*|jjtjkr>td��ntd�|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�rLr�r�r�r�r�r/rrrr�7s

��zSharedMemoryManager.get_servercCs�|j|j|jd��h}tjdd|d�}zt|dd|jf�Wn0tyj}z|��|�WYd}~n
d}~00Wd�n1s�0Y|S)zoReturns a new SharedMemory instance with the specified size in
            bytes, to be tracked by the manager.r�NT)rZ�sizer�)	r�r�r�rr�rEr�
BaseExceptionr�)r-r�r�Zsmsr�rrrr�Ds8z SharedMemoryManager.SharedMemorycCs�|j|j|jd��f}t�|�}zt|dd|jjf�Wn2tyh}z|j�	�|�WYd}~n
d}~00Wd�n1s~0Y|S)z�Returns a new ShareableList instance populated with the values
            from the input sequence, to be tracked by the manager.r�Nr�)
r�r�r�r�
ShareableListrEZshmrr�r�)r-r/r�Zslr�rrrr�Ps

8z!SharedMemoryManager.ShareableListN)r5r7r8r9r�r�r.r�r�r�r�rrrrrs	
)NNNTF)T)U�__all__r�rnr�rZqueuer@rTr�rr�rr�r	�contextr
rrr
rrrr�ImportErrorZ	HAS_SHMEMrRrr�Z
view_typesr%r(Z	view_typerOrrEr>r�rMrUrWrXr�rrrsZXmlListenerZ	XmlClientrirr�rrrr%r�r&r)r0r1r6r;rCrErLrSrWrhrjr�rnZ
BasePoolProxyrorrwrurorxryrzr{r|r}r�r~r�rrrrr�<module>s�



H

�	w
4�



	
�

�

�%-

Hacked By AnonymousFox1.0, Coded By AnonymousFox