%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core20/current/lib/python3.8/multiprocessing/__pycache__/
Upload File :
Create Path :
Current File : //snap/core20/current/lib/python3.8/multiprocessing/__pycache__/managers.cpython-38.pyc

U

k�]e��@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�./usr/lib/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@s4eZdZdZdZdd�Zdd�Zdd�Zd	d
�ZdS)rz3
    Type to uniquely identify a shared object
    ��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__�__doc__�	__slots__r-r/r2r5rrrrr<srcCs8|�||||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�dispatchSs
rDcCsd|dkr|S|dkrRt|t�s4td�||t|����|dkrHtd|�St|�Sntd�|��SdS)N�#ERROR)�
#TRACEBACK�#UNSERIALIZABLEz.Result {0!r} (kind '{1}') type is {2}, not strrGzUnserializable message: %s
zUnrecognized message type {!r})�
isinstance�str�	TypeError�formatr�RemoteError�
ValueError)rBrCrrrr=]s
��
r=c@seZdZdd�ZdS)rLcCsdt|jd�dS)NzM
---------------------------------------------------------------------------
rzK---------------------------------------------------------------------------)rIr@r.rrr�__str__mszRemoteError.__str__N)r4r6r7rNrrrrrLlsrLcCs2g}t|�D] }t||�}t|�r|�|�q|S)z4
    Return a list of names of methods of `obj`
    )�dirr�callable�append)r&�tempr�funcrrr�all_methodsts
rTcCsdd�t|�D�S)zP
    Return a list of names of methods of `obj` which do not start with '_'
    cSsg|]}|ddkr|�qS)r�_rrrrrr �sz"public_methods.<locals>.<listcomp>)rTr%rrr�public_methodssrVc	@s�eZdZdZdddddddd	d
g	Zdd�Zd
d�Zdd�Zdd�Zdd�Z	dd�Z
dd�Zdd�Zeee
d�Z
dd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&e_d'd(�Zd)d*�Zd+d,�Zd-d.�Zd/S)0�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)rH�bytesrJrKr�registryr�AuthenticationString�authkey�listener_client�listenerr*�	id_to_obj�id_to_refcount�id_to_local_proxy_obj�	threading�Lock�mutex)r,rer*rg�
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)z(
        Run the server forever
        zresetting stdout, stderrr)�targetTr	N)rm�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,r�rrr�
serve_forever�s 




zServer.serve_forevercCsNz|j��}Wntk
r&YqYnXtj|j|fd�}d|_|��qdS)N�rsr@T)riZaccept�OSErrorrmr�handle_requestr�r�)r,r>�trrrr��s
zServer.acceptercCsLd}}}zTt�||j�t�||j�|��}|\}}}}||jksTtd|��t||�}Wntk
r~dt	�f}	Yn>Xz||f|�|�}Wntk
r�dt	�f}	Yn
Xd|f}	z|�
|	�Wnttk
�r>}
zTz|�
dt	�f�Wntk
�rYnXt�d|	�t�d|�t�d|
�W5d}
~
XYnX|�
�dS)z)
        Handle a new connection
        Nz%r unrecognizedrFr:zFailure to send message: %rz ... request was %r� ... exception was %r)r
Zdeliver_challengergZanswer_challenger<�public�AssertionErrorr�	Exceptionrr;r�info�close)r,r>�funcnamerC�request�ignorer@rArS�msg�errrr��s4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�dt��j�t�d|�t�d
|�|��t�d�W5d}~XYq$Xq$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=%rrE�#PROXYr:rFz$got EOF -- exiting thread serving %rrrGzexception in thread serving %rz ... message was %rr�r	)rr{rm�current_threadrr<r;rjrur��KeyErrorrl�AttributeErrorrrr��getrYrr*r�fallback_mapping�EOFErrorrxr~r�r�)r,�connr<r;rjr?r&r��identr@rA�exposed�	gettypeid�keZ	second_keZfunction�resr�r�r)ZridentZrexposed�tokenZ
fallback_funcrCrrr�serve_client�s���(��


����$�zServer.serve_clientcCs|Srr�r,r�r�r&rrr�fallback_getvalue5szServer.fallback_getvaluecCst|�Sr�rIr�rrr�fallback_str8szServer.fallback_strcCst|�Sr)�reprr�rrr�
fallback_repr;szServer.fallback_repr)rNr5�	#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)zO
        Return some info --- useful to spot problems with refcounting
        rbz  %s:       refcount=%s
    %srN�K�
)	ror$rkr"�sortrQrIrj�join)r,r>rCr"r�rrrr\Gs
��zServer.debug_infocCs
t|j�S)z*
        Number of shared objects
        )�lenrkr�rrrr]WszServer.number_of_objectscCsLz:zt�d�|�d�Wnddl}|��YnXW5|j��XdS)z'
        Shutdown this process
        z!manager received shutdown message�r:NrN)ru�setrr{r;�	traceback�	print_exc)r,r>r�rrrrX^s
zServer.shutdownc	Os�t|�dkr|^}}}}n�|s(td��n�d|krDtdt|�d��|�d�}t|�dkr~|^}}}ddl}|jd	tdd
�nFd|kr�tdt|�d��|�d�}|^}}ddl}|jdtdd
�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)z>
        Create a new shared object and return its id
        �z8descriptor 'create' of 'Server' object needs an argumentr)�7create expected at least 2 positional arguments, got %dr	�rNz2Passing '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�rJ�pop�warnings�warn�DeprecationWarning�tuplerorerMrVrH�dictrKrr$r+rr{r�rjrkr_)r@rAr,r>r)r�rPr��method_to_typeid�	proxytyper&r�rrrrYksp

�

�
�
��

�



��z
Server.createz$($self, c, typeid, /, *args, **kwds)cCst|j|jd�S)zL
        Return the methods of the shared object indicated by token
        r	)r�rjr+)r,r>r�rrrr[�szServer.get_methodscCs"|t��_|�d�|�|�dS)z=
        Spawn a new thread to serve this connection
        r�N)rmr�rr;r�)r,r>rrrrrZ�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)rorkr�rlrjrr{)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)rkrlrr{ror�rKrj)r,r>r�rrrr`�s,
���

z
Server.decrefN)r4r6r7r8r�r-r�r�r�r�r�r�r�r�r^r\r]rXrY�__text_signature__r[rZr_r`rrrrrW�s<�
"Q�
=rWc@seZdZdgZdZdZdZdS)�State�valuerr	r�N)r4r6r7r9�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\|dkrt��j}||_t�|�|_t�|_tj|j_	||_
t|\|_|_
|pTt�|_dSr)rrvrg�_addressrf�_authkeyr��_stater�r��_serializerrhZ	_Listener�_Clientr�_ctx)r,r*rgrpZctxrrrr-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�rKrW�	_registryr�r�r�r.rrr�
get_servers

�
�zBaseManager.get_servercCs8t|j\}}||j|jd�}t|dd�tj|j_dS)z>
        Connect manager object to the server process
        �rgNr^)	rhr�r�r�rDr�r�r�r�)r,rqrrr�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)z@
        Spawn a server process for this manager object
        r�r�r�Nzinitializer 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�rKrPrJr
ZPiper�ZProcessr�_run_serverr�r�r�r��_processr�Z	_identityr4rr�r�r<r�Finalize�_finalize_managerr�rX)r,�initializer�initargs�reader�writerr�rrrr�(sH

���


��zBaseManager.startc	Cs^t�tjtj�|dk	r ||�|�||||�}|�|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�)	�clsrer*rgrpr�r�r��serverrrrr�SszBaseManager._run_servercOsd|jjtjkstd��|j|j|jd�}zt	|dd|f||�\}}W5|��Xt
||j|�|fS)zP
        Create a new shared object; return the token and exposed tuple
        zserver not yet startedr�NrY)r�r�r�r�r�r�r�r�r�rDr)r,r)r@rAr�r+r�rrr�_createjs
zBaseManager._createcCs*|jdk	r&|j�|�|j��s&d|_dS)zC
        Join the manager process (if it has been spawned)
        N)r�r��is_alive�r,�timeoutrrrr�vs

zBaseManager.joincCs2|j|j|jd�}zt|dd�W�S|��XdS)zS
        Return some info about the servers shared objects and connections
        r�Nr\�r�r�r�r�rD�r,r�rrr�_debug_infoszBaseManager._debug_infocCs2|j|j|jd�}zt|dd�W�S|��XdS)z5
        Return the number of shared objects
        r�Nr]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�rKr.rrr�	__enter__�s

�zBaseManager.__enter__cCs|��dSr)rX�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)zQ
        Shutdown the manager process; will be registered as a finalizer
        z#sending shutdown message to managerr�NrXg�?)r�zmanager still alive�	terminatez'trying to `terminate()` manager processg�������?z#manager still alive after terminate)r�rr�r�rDr�r��hasattrr�r�r�r�r�_address_to_localr�)rr*rgr1r�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]8\}}t|�tksrt	d|��t|�tksRt	d|��qR|||�f|j�<|r‡�fdd�}	�|	_
t|�|	�dS)z9
        Register a typeid with the manager type
        r�N�	_exposed_�_method_to_typeid_z%r is not a stringcs`t�d��|j�f|�|�\}}�||j||j|d�}|j|j|jd�}t|dd|jf�|S)Nz)requesting creation of a shared %r object��managerrgr�r�r`)	rr{r�r�r�r�r*rDr+)r,r@rAr�Zexp�proxyr��r�r)rrrR�s�z"BaseManager.register.<locals>.temp)�__dict__r��copy�	AutoProxyrr$r!rrIr�r4�setattr)
r�r)rPr�r�r��
create_method�keyr�rRrr�r�register�s*

��

zBaseManager.register)NNr�N)Nr)Nr)N)NNNNT)r4r6r7r8r�rWr�r-r�r�r��classmethodr�r�r�r�r�r�r��staticmethodr��propertyr*rrrrrr�s8�
	
+�
	




�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|�dfSrc)rr.rrr�
__reduce__�szProcessLocalSet.__reduce__N)r4r6r7r-rrrrrr	�sr	c@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�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�rhr��_owned_by_managerrrfr�rvrg�_increfr
�_after_fork)	r,r�rpr�rgr�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�rZ)rr{rrvrrmr�r�rr*r�rDrr
)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)	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�Nr`)rr
r�rr{rmr�rrr;rr<rr�r)rr*r�r�r�rDr+r=)r,r?r@rAr�rBrCr�r�r�r�rrr�_callmethod6s6�
�zBaseProxy._callmethodcCs
|�d�S)z9
        Get a copy of the value of the referent
        r��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�)rrr{rr+r�r*r�rDrr�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�rr{r*rDr�r�rmr�rr
r�)r�rgr1ZtlsZidsetr�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)Nrg�_isautoFr�)	rr�rr��RebuildProxyrrr�r�r,rArrrr�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)zV
        Return representation of the referent (or a fall-back if that fails)
        r5Nrz; '__str__()' failed>)rr�r�r.rrrrN�szBaseProxy.__str__)NNNTF)r4r6r7r8r�rZForkAwareThreadLockrr-rrrrrr!rrr&r5rNrrrrr�s(�
)	

cCs�tt��dd�}|rT|j|jkrTt�d|�d|d<|j|jkrT|j|j|j|j<|�	dd�optt��dd�}|||fd|i|��S)	z5
    Function used for unpickling proxy objects.
    rwNz*Rebuild a proxy owned by manager, token=%rTrr_Z_inheritingF)
rrrvr*rr{r+rlrjr�)rSr�rprAr�r_rrrr$�s
�
�r$cCspt|�}z|||fWStk
r*YnXi}|D]}td||f|�q4t|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*c
Cs�t|d}|dkrB||j|d�}zt|dd|f�}W5|��X|dkrX|dk	rX|j}|dkrjt��j}td|j	|�}||||||d�}	d|	_
|	S)z*
    Return an auto-proxy for `token`
    r	Nr�r[z
AutoProxy[%s])r�rgr_T)rhr*r�rDr�rrvrgr*r)r#)
r�rpr�rgr�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)NrUz%s=%rz%s(%s)z, )	r$r�r!�
startswithrQr�r3r4r�)r,r!rRrr�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�r0r.rrrr�sz	Value.getcCs
||_dSrr2�r,r�rrrr�
sz	Value.setcCsdt|�j|j|jfS)Nz
%s(%r, %r))rr4r/r0r.rrrr5szValue.__repr__N)T)	r4r6r7r-r�r�r5rr�rrrrr.s

r.cCst�||�Sr)r)r�sequencer1rrr�Arraysr5c@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�
IteratorProxy)�__next__r;�throwr�cCs|Srrr.rrr�__iter__szIteratorProxy.__iter__cGs|�d|�S)Nr7r�r,r@rrrr7szIteratorProxy.__next__cGs|�d|�S)Nr;rr:rrrr;szIteratorProxy.sendcGs|�d|�S)Nr8rr:rrrr8szIteratorProxy.throwcGs|�d|�S)Nr�rr:rrrr�!szIteratorProxy.closeN)	r4r6r7r�r9r7r;r8r�rrrrr6sr6c@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)NrAr)r,�nrrrrA6szConditionProxy.notifycCs
|�d�S)NrBrr.rrrrB8szConditionProxy.notify_allcCsd|�}|r|S|dk	r$t��|}nd}d}|s`|dk	rN|t��}|dkrNq`|�|�|�}q,|S)Nr)�time�	monotonicr�)r,Z	predicater�rCZendtimeZwaittimerrr�wait_for:s
zConditionProxy.wait_for)N)r	)N)r4r6r7r�r�rArBrGrrrrr@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�SrCrr�rrrr�UszEventProxy.wait)N)r4r6r7r�r�r�r
r�rrrrrHMs
rHc@sNeZdZdZddd�Zdd�Zdd�Zed	d
��Zedd��Z	ed
d��Z
dS)�BarrierProxy)�__getattribute__r��abort�resetNcCs|�d|f�SrCrr�rrrr�[szBarrierProxy.waitcCs
|�d�S)NrLrr.rrrrL]szBarrierProxy.abortcCs
|�d�S)NrMrr.rrrrM_szBarrierProxy.resetcCs|�dd�S)NrK)�partiesrr.rrrrNaszBarrierProxy.partiescCs|�dd�S)NrK)�	n_waitingrr.rrrrOdszBarrierProxy.n_waitingcCs|�dd�S)NrK)�brokenrr.rrrrPgszBarrierProxy.broken)N)r4r6r7r�r�rLrMrrNrOrPrrrrrJYs


rJc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�NamespaceProxy)rK�__setattr__�__delattr__cCs0|ddkrt�||�St�|d�}|d|f�S)NrrUrrK)�objectrK�r,r�
callmethodrrr�__getattr__nszNamespaceProxy.__getattr__cCs4|ddkrt�|||�St�|d�}|d||f�S)NrrUrrR)rTrRrK)r,rr�rVrrrrRsszNamespaceProxy.__setattr__cCs0|ddkrt�||�St�|d�}|d|f�S)NrrUrrS)rTrSrKrUrrrrSxszNamespaceProxy.__delattr__N)r4r6r7r�rWrRrSrrrrrQlsrQc@s*eZdZdZdd�Zdd�Zeee�ZdS)�
ValueProxy)r�r�cCs
|�d�S)Nr�rr.rrrr��szValueProxy.getcCs|�d|f�SrIrr3rrrr��szValueProxy.setN)r4r6r7r�r�r�rr�rrrrrXsrX�
BaseListProxy)�__add__�__contains__�__delitem__�__getitem__�__len__�__mul__�__reversed__�__rmul__�__setitem__rQ�count�extend�index�insertr��remove�reverser��__imul__c@seZdZdd�Zdd�ZdS)�	ListProxycCs|�d|f�|S)Nrdrr3rrr�__iadd__�szListProxy.__iadd__cCs|�d|f�|S)Nrirr3rrrri�szListProxy.__imul__N)r4r6r7rkrirrrrrj�srj�	DictProxy)r[r\r]r9r^rbr
rr�r!r"r��popitem�
setdefaultr,r#r9�Iterator�
ArrayProxy)r^r]rb�	PoolProxy)Zapply�apply_asyncr��imap�imap_unorderedr��map�	map_async�starmap�
starmap_asyncr�ZAsyncResult)rrrvrxrsrtc@seZdZdd�Zdd�ZdS)rqcCs|Srrr.rrrr��szPoolProxy.__enter__cCs|��dSr)r�r�rrrr��szPoolProxy.__exit__N)r4r6r7r�r�rrrrrq�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)r4r6r7r8rrrrr�s�QueueZ
JoinableQueuertrn�RLock�	Semaphore�BoundedSemaphore�	Condition�Barrier�Poolr$r�)r�r)rc@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�rQ�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�rgr�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{r3r4rr�r.rrr�__del__�sz_SharedMemoryTracker.__del__cCs|j|jfSrr�r.rrrr/�sz!_SharedMemoryTracker.__getstate__cCs|j|�dSr)r-r0rrrr2sz!_SharedMemoryTracker.__setstate__N)r4r6r7r8r-r�r�r�r�r/r2rrrrr��s	r�c@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_rUz"SharedMemoryServer started by pid )rWr-r*rHrd�os�fsdecoder�r�shared_memory_contextrr{)r,r@�kwargsr*rrrr-
s

�zSharedMemoryServer.__init__cOstt|�dkr|d}n4d|kr(|d}n"|s6td��ntdt|�d��ttj|dd�rhtj|d	<tj||�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.r�r�r)zDdescriptor 'create' of 'SharedMemoryServer' object needs an argumentr�r	rZ_shared_memory_proxyr�)r�rJr�r,rer�rWrY)r@r�Ztypeodr)rrrrYs



�
zSharedMemoryServer.createz&($self, c, typeid, /, *args, **kwargs)cCs|j��t�||�S)zACall unlink() on all tracked shared memory, terminate the Server.)r�r�rWrXr�rrrrX)s
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�2sz"SharedMemoryServer.release_segmentcCs|jjS)zbReturns a list of names of shared memory blocks that the Server
            is currently tracking.)r�r�r�rrrr�7sz SharedMemoryServer.list_segmentsN)r4r6r7rWr�r-rYr�rXr�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).
        cOsNtjdkrddlm}|��tj|f|�|�t�|j	j
�dt����dS)N�posixr	)�resource_trackerz created by pid )r�r�r�Zensure_runningrr-rr{r3r4r)r,r@r�r�rrrr-Is

zSharedMemoryManager.__init__cCst�|jj�dt����dS)Nz.__del__ by pid )rr{r3r4rr.rrrr�UszSharedMemoryManager.__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�rKr�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)zoReturns a new SharedMemory instance with the specified size in
            bytes, to be tracked by the manager.r�NT)rY�sizer�)	r�r�r�rr�rDr�
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)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�
ShareableListrDZshmrr�r�)r,r4r�Zslr�rrrr�rs

 z!SharedMemoryManager.ShareableListN)r4r6r7r8r�r�r-r�r�r�r�rrrrr=s	
)NNNT)T)S�__all__rxrmr�rZqueuerEr�rr�rr�r
�contextrrr
rrrrrZ	HAS_SHMEM�ImportErrorrrZ
view_typesr$r'Z	view_typerTrrDr=r�rLrTrVrWr�rqrrZXmlListenerZ	XmlClientrhrr�r	rr$r*rr+r.r5r6r;r@rHrJrQrXrYrjrlr�rpZ
BasePoolProxyrqrryrtrnrzr{r|r}r~rr�r�r�rrrrr�<module>s��


c

�	w
4�


	
	
�

�

�%8

Zerion Mini Shell 1.0