AlkantarClanX12

Your IP : 52.14.209.100


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

a

R�f�G�@s�ddgZddlmZddlZddlZddlZddlZddlZddlZej	dkr\ddl
Z
dZnddlZdZej
ejBZdZer�d	Znd
Zdd�ZGd
d�d�ZdZGdd�d�ZdS)�SharedMemory�
ShareableList�)�partialN�ntFT�z/psm_Zwnsm_cCs"ttt�d}tt�|�}|S)N�)�_SHM_SAFE_NAME_LENGTH�len�_SHM_NAME_PREFIX�secretsZ	token_hex)�nbytes�name�r�B/opt/alt/python39/lib64/python3.9/multiprocessing/shared_memory.py�_make_filename'src@s�eZdZdZdZdZdZejZ	dZ
er*dndZddd�Z
d	d
�Zdd�Zd
d�Zedd��Zedd��Zedd��Zdd�Zdd�ZdS)rN���i�TFrc
	Cs�|dkstd��|r0ttjB|_|dkr0td��|durL|jtj@sLtd��t�rD|dur�t�}ztj	||j|j
d�|_Wnty�YqZYn0||_
q�qZn.|jr�d|n|}tj	||j|j
d�|_||_
z<|r�|r�t�|j|�t�|j�}|j}t�|j|�|_Wnt�y&|���Yn0ddlm}||j
d	��n*|�r|du�rZt�n|}t�tjtjtj|d
?d@|d@|�}zjt��}|tjk�r�|du�r�ttj t�!tj �|tj��nWt�"|��qJtjd||d
�|_Wt�"|�nt�"|�0||_
�qn�qJnb||_
t�#tj$d|�}z"t�%|tj$ddd�}	Wt�"|�nt�"|�0t�&|	�}tjd||d
�|_||_'t(|j�|_)dS)Nrz!'size' must be a positive integerz4'size' must be a positive number different from zeroz&'name' can only be None if create=True)�mode�/�)�register�
shared_memory� l��r)ZtagnameF)*�
ValueError�_O_CREX�os�O_RDWR�_flags�O_EXCL�
_USE_POSIXr�_posixshmemZshm_open�_mode�_fd�FileExistsError�_name�_prepend_leading_slash�	ftruncate�fstat�st_size�mmap�_mmap�OSError�unlink�resource_trackerr�_winapiZCreateFileMappingZINVALID_HANDLE_VALUEZNULLZPAGE_READWRITEZGetLastErrorZERROR_ALREADY_EXISTS�errnoZEEXIST�strerrorZCloseHandleZOpenFileMappingZ
FILE_MAP_READZ
MapViewOfFileZVirtualQuerySize�_size�
memoryview�_buf)
�selfr
�create�sizeZstatsrZ	temp_nameZh_mapZlast_error_codeZp_bufrrr�__init__Js��
�
�

�
�
��
zSharedMemory.__init__cCs$z|��WntyYn0dS�N)�closer*�r3rrr�__del__�szSharedMemory.__del__cCs|j|jd|jffS)NF)�	__class__r
r5r9rrr�
__reduce__�s��zSharedMemory.__reduce__cCs|jj�d|j�d|j�d�S)N�(z, size=�))r;�__name__r
r5r9rrr�__repr__�szSharedMemory.__repr__cCs|jSr7)r2r9rrr�buf�szSharedMemory.bufcCs.|j}tr*|jr*|j�d�r*|jdd�}|S)Nrr)r#rr$�
startswith)r3Z
reported_namerrrr
�s

zSharedMemory.namecCs|jSr7)r0r9rrrr5�szSharedMemory.sizecCsX|jdur|j��d|_|jdur4|j��d|_trT|jdkrTt�|j�d|_dS)Nrr)r2�releaser)r8rr!rr9rrrr8�s



zSharedMemory.closecCs2tr.|jr.ddlm}t�|j�||jd�dS)Nr)�
unregisterr)rr#r,rDrZ
shm_unlink)r3rDrrrr+�s
zSharedMemory.unlink)NFr)r?�
__module__�__qualname__r#r!r)r2rrrr rr$r6r:r<r@�propertyrAr
r5r8r+rrrrr1s&
l




�utf8c@seZdZedededededdjdiZ	dZ
dd	�d
d	�dd	�dd	�d
�Zedd��Z
d5dd�dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zed#d$��Zed%d&��Zed'd(��Zed)d*��Zed+d,��Zed-d.��Zed/d0��Zd1d2�Zd3d4�Z e!e"j#�Z$dS)6r�q�dzxxxxxxx?z%dsNzxxxxxx?x�cCs|Sr7r��valuerrr�<lambda>�zShareableList.<lambda>cCs|�d��t�S�N�)�rstrip�decode�	_encodingrLrrrrNrOcCs
|�d�SrP)rRrLrrrrNrOcCsdSr7r)Z_valuerrrrNrO)rrr�cCs:t|ttdjf�sdSt|t�r$dSt|t�r2dSdSdS)NrrrrU)�
isinstance�str�bytesr;rLrrr�_extract_recreation_codes

z&ShareableList._extract_recreation_code�r
cs�|dus|dur�|pd}�fdd�|D�}t|��_d}dg�_|D]6}||ddkr\�jnt|dd��7}�j�|�qD�fdd�|D�}t�d�jd	�	|��j
�j�}t|d
|d��_
n
t|��_
|du�r�t�tjd�j�j
jd�jg�j�R�tjd	�	|��j
j�jg�fdd
�|D��R�tj�j
�j
j�jg�fdd
�|D��R�tj�j�j
j�jg|�R�n$t���_tt��j�j
jd���_dS)NrcsPg|]H}t|ttf�s$�jt|�n&�jt|��jt|��jdf�qS)r)rVrWrX�_types_mapping�type�
_alignmentr	��.0�itemr9rr�
<listcomp>+s���z*ShareableList.__init__.<locals>.<listcomp>rr�scsg|]}��|��qSr)rYr^r9rrra=srI�T)r4r5c3s&|]}t|t�r|���n|VqdSr7)rVrW�encode�r_�v��_encrr�	<genexpr>XrOz)ShareableList.__init__.<locals>.<genexpr>c3s|]}|���VqdSr7)rdrergrrri^rOrK)r	�	_list_len�_allocated_offsetsr]�int�append�structZcalcsize�_format_size_metainfo�join�_format_packing_metainfo�_format_back_transform_codesr�shmrT�	pack_intorA�_offset_data_start�_offset_packing_formats�_offset_back_transform_codes�list�unpack_from)r3Zsequencer
Z_formats�offset�fmtZ_recreation_codesZrequested_sizer)rhr3rr6(s�
�
&
�����

��������

��zShareableList.__init__cCsj|dkr|n||j}||jks*|jdkr2td��t�d|jj|j|d�d}|�d�}|�t	�}|S)Nr� Requested position out of range.�8srKrQ)
rj�
IndexErrorrnryrsrArvrRrSrT)r3�positionrfr{�
fmt_as_strrrr�_get_packing_formatqs��

z!ShareableList._get_packing_formatcCsF||jks|jdkrtd��t�d|jj|j|�d}|j|}|S)Nrr|�b)rjr~rnryrsrArw�_back_transforms_mapping)r3r�transform_codeZtransform_functionrrr�_get_back_transform�s��
z!ShareableList._get_back_transformcCsh||jks|jdkrtd��t�d|jj|j|d|�t��|�	|�}t�d|jj|j
||�dS)Nrr|r}rKr�)rjr~rnrtrsrArvrdrTrYrw)r3rr�rMr�rrr�!_set_packing_format_and_transform�s�
�z/ShareableList._set_packing_format_and_transformcCsv|dkr|n||j}z.|j|j|}t�|�|�|jj|�\}Wnty^td��Yn0|�	|�}||�}|S)Nrzindex out of range)
rjrurkrnryr�rsrAr~r�)r3rrzrfZback_transformrrr�__getitem__�s�

zShareableList.__getitem__c	Cs�|dkr|n||j}z"|j|}|j|}|�|�}WntyRtd��Yn0t|ttf�sv|jt	|�}|}n`|j|d|}t|t�r�|�
t�n|}t|�|kr�t
d��|ddkr�|}n|jt|f}|�|||�t�||jj||�dS)Nrzassignment index out of rangerz(bytes/str item exceeds available storagerrb)rjrkrur�r~rVrWrXr[r\rdrTr	rr�rnrtrsrA)	r3rrMZitem_offsetrzZcurrent_formatZ
new_formatZ
encoded_valueZallocated_lengthrrr�__setitem__�s8

����zShareableList.__setitem__cCst|j|jjd�dfS)NrZr)rr;rsr
r9rrrr<�szShareableList.__reduce__cCst�d|jjd�dS)NrIr)rnryrsrAr9rrr�__len__�szShareableList.__len__cCs"|jj�dt|��d|jj�d�S)Nr=z, name=r>)r;r?rxrsr
r9rrrr@�szShareableList.__repr__csd��fdd�t�j�D��S)Nrcc3s|]}��|�VqdSr7)r�)r_�ir9rrri�sz'ShareableList.format.<locals>.<genexpr>)rp�rangerjr9rr9r�format�s�zShareableList.formatcCsd|jdS)NrIr�rjr9rrrro�sz#ShareableList._format_size_metainfocCs
d|jS)Nr}r�r9rrrrq�sz&ShareableList._format_packing_metainfocCs
d|jS)Nr�r�r9rrrrr�sz*ShareableList._format_back_transform_codescCs|jddS)NrrKr�r9rrrru�sz ShareableList._offset_data_startcCs|j|jdS)Nr)rurkr9rrrrv�sz%ShareableList._offset_packing_formatscCs|j|jdS)NrK)rvrjr9rrrrwsz*ShareableList._offset_back_transform_codescst�fdd�|D��S)Nc3s|]}�|kVqdSr7r)r_�entryrLrrrirOz&ShareableList.count.<locals>.<genexpr>)�sum)r3rMrrLr�countszShareableList.countcCs4t|�D]\}}||kr|Sqt|�d���dS)Nz not in this container)�	enumerater)r3rMrr�rrr�index
s
zShareableList.index)N)%r?rErFrl�float�boolrWrXr;r[r]r��staticmethodrYr6r�r�r�r�r�r<r�r@rGr�rorqrrrurvrwr�r��classmethod�types�GenericAlias�__class_getitem__rrrrr�sR��

I!







)�__all__�	functoolsrr(rr.rnrr�r
r-rr�O_CREATrrrr
rrrTrrrrr�<module>s,

E