AlkantarClanX12

Your IP : 3.135.209.107


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

�

c��fH���dZddgZddlmZddlZddlZddlZddlZddlZddl	Z	ej
dkrddlZdZnddl
Z
dZd	d
lmZejejzZdZerdZnd
Zd�ZGd�d��ZdZGd�d��ZdS)z�Provides shared memory for direct access across processes.

The API of this package is currently provisional. Refer to the
documentation for details.
�SharedMemory�
ShareableList�)�partialN�ntFT�)�resource_tracker�z/psm_�wnsm_c���ttt��z
dz}|dks
Jd���ttj|��z}t|��tksJ�|S)z6Create a random filename for the shared memory object.�z_SHM_NAME_PREFIX too long)�_SHM_SAFE_NAME_LENGTH�len�_SHM_NAME_PREFIX�secrets�	token_hex)�nbytes�names  �D/opt/alt/python311/lib64/python3.11/multiprocessing/shared_memory.py�_make_filenamer(sb��$�c�*:�&;�&;�;��
A�F��Q�;�;�;�3�;�;�;��g�/��7�7�7�D��t�9�9�-�-�-�-�-��K�c��eZdZdZdZdZdZdZej	Z
dZerdndZ
dd�Zd	�Zd
�Zd�Zed���Zed
���Zed���Zd�Zd�ZdS)ra�Creates a new shared memory block or attaches to an existing
    shared memory block.

    Every shared memory block is assigned a unique name.  This enables
    one process to create a shared memory block with a particular name
    so that a different process can attach to that same shared memory
    block using that same name.

    As a resource for sharing data across processes, shared memory blocks
    may outlive the original process that created them.  When one process
    no longer needs access to a shared memory block that might still be
    needed by other processes, the close() method should be called.
    When a shared memory block is no longer needed by any process, the
    unlink() method should be called to ensure proper cleanup.N���i�TFrc�x�|dkstd���|r.ttjz|_|dkrtd���|�#|jtjzstd���t�r*|�O	t��}	tj	||j|j
���|_n#t$rY�CwxYw||_
n;|jrd|zn|}tj	||j|j
���|_||_
	|r|rtj|j|��tj|j��}|j}t%j|j|��|_n##t($r|����wxYwt-j|j
d���n�|�r#	|�t��n|}t1jt0jt0jt0j|d	z	d
z|d
z|��}	t1j��}|t0jkrZ|�Btt>j tj!t>j ��|t0j���	t1j"|����t%jd||���|_t1j"|��n#t1j"|��wxYw||_
n�||_
t1j#t0j$d
|��}	t1j%|t0j$ddd��}t1j"|��n#t1j"|��wxYw	t1j&|��}t1j'|��n#t1j'|��wxYwt%jd||���|_||_(tS|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=TrueT)�mode�/�
shared_memory� l��r)�tagnameF)+�
ValueError�_O_CREX�os�O_RDWR�_flags�O_EXCL�
_USE_POSIXr�_posixshmem�shm_open�_mode�_fd�FileExistsError�_name�_prepend_leading_slash�	ftruncate�fstat�st_size�mmap�_mmap�OSError�unlinkr�register�_winapi�CreateFileMapping�INVALID_HANDLE_VALUE�NULL�PAGE_READWRITE�GetLastError�ERROR_ALREADY_EXISTS�errno�EEXIST�strerror�CloseHandle�OpenFileMapping�
FILE_MAP_READ�
MapViewOfFile�VirtualQuerySize�UnmapViewOfFile�_size�
memoryview�_buf)	�selfr�create�size�stats�	temp_name�h_map�last_error_code�p_bufs	         r�__init__zSharedMemory.__init__Ks����q�y�y��@�A�A�A��	Y�!�B�I�-�D�K��q�y�y� �!W�X�X�X��<���b�i� 7�<��E�F�F�F��_	?��|��)�+�+�D�!�#.�#7� � �K�!%��$�$�$�����
+�!�!�!� ��!����!%�D�J��%)�%@�J�s�T�z�z�d��&�/���K��������
"��
�
��1�d�1��L���4�0�0�0�����*�*���}��!�Y�t�x��6�6��
�
���
�
�
����
�
�
��
����
�%�d�j�/�B�B�B�B��6
?��48�L�� 0� 0� 0�d�I�$�5��4����.����z�1��z�)�!�
��E�3�*1�*>�*@�*@��*�g�.J�J�J�#�/�&5�$)�L�$&�K���$=�$=�$(�$+�$@�	'"�'"�!"�!)� �+�E�2�2�2�2�&*�Y�r�4��%K�%K�%K��
��+�E�2�2�2�2���+�E�2�2�2�2����!*�D�J��"��
� �/��)������
	/�#�1���-������E��'��.�.�.�.��G�'��.�.�.�.����3�"�3�E�:�:�D��+�E�2�2�2�2��G�+�E�2�2�2�2����!�Y�r�4��>�>�>��
���
��t�z�*�*��	�	�	sJ�&B,�,
B9�8B9�AE� E>�4A'J"�1J"�"J8�+"L"�"L8�<M%�%M;c�R�	|���dS#t$rYdSwxYw�N)�closer2�rHs r�__del__zSharedMemory.__del__�s:��	��J�J�L�L�L�L�L���	�	�	��D�D�	���s��
&�&c�.�|j|jd|jffS)NF)�	__class__rrJrTs r�
__reduce__zSharedMemory.__reduce__�s#���N��	���	�
�
�	
rc�@�|jj�d|j�d|j�d�S)N�(z, size=�))rW�__name__rrJrTs r�__repr__zSharedMemory.__repr__�s*���.�)�L�L�D�I�L�L��	�L�L�L�Lrc��|jS)z4A memoryview of contents of the shared memory block.)rGrTs r�bufzSharedMemory.buf�s���y�rc��|j}tr0|jr)|j�d��r|jdd�}|S)z4Unique name that identifies the shared memory block.rrN)r+r%r,�
startswith)rH�
reported_names  rrzSharedMemory.name�sJ���
�
��	/�$�5�	/��z�$�$�S�)�)�
/� $�
�1�2�2��
��rc��|jS)zSize in bytes.)rErTs rrJzSharedMemory.size�s���z�rc��|j� |j���d|_|j� |j���d|_tr-|jdkr$t
j|j��d|_dSdSdS)zkCloses access to the shared memory from this instance but does
        not destroy the shared memory block.Nrr)rG�releaser1rSr%r)r!rTs rrSzSharedMemory.close�s����9� ��I�������D�I��:�!��J�������D�J��	�$�(�a�-�-��H�T�X�����D�H�H�H�	�	�-�-rc��tr<|jr7tj|j��t	j|jd��dSdSdS)z�Requests that the underlying shared memory block be destroyed.

        In order to ensure proper cleanup of resources, unlink should be
        called once (and only once) across all processes which have access
        to the shared memory block.rN)r%r+r&�
shm_unlinkr�
unregisterrTs rr3zSharedMemory.unlink�s]���	E�$�*�	E��"�4�:�.�.�.��'��
�O�D�D�D�D�D�	E�	E�	E�	Er)NFr)r\�
__module__�__qualname__�__doc__r+r)r1rGr!r"r#r(r%r,rPrUrXr]�propertyr_rrJrSr3�rrrr2s������
B�
B� 
�E�
�C��E��D�
�Y�F��E�%/�:�T�T�U��l+�l+�l+�l+�\���
�
�
�M�M�M�����X������X������X�����E�E�E�E�Er�utf8c�l�eZdZdZedededededdj	diZ
dZd	�d
�d�d�d
�Ze
d���Zd"dd�d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zed���Zed���Zed���Zed���Zed���Zed���Zed���Zd �Z d!�Z!e"e#j$��Z%dS)#ra�Pattern for a mutable list-like object shareable via a shared
    memory block.  It differs from the built-in list type in that these
    lists can not change their overall length (i.e. no append, insert,
    etc.)

    Because values are packed into a memoryview as bytes, the struct
    packing format for any storable value must require no more than 8
    characters to describe its format.�q�dzxxxxxxx?z%dsNzxxxxxx?x�c��|SrRrm��values r�<lambda>zShareableList.<lambda>s���rc�\�|�d���t��S�N�)�rstrip�decode�	_encodingrts rrvzShareableList.<lambda>s �����g�.�.�5�5�i�@�@�rc�,�|�d��Srx)rzrts rrvzShareableList.<lambda>s�����g�.�.�rc��dSrRrm)�_values rrvzShareableList.<lambda>s��$�r)rrr�c��t|ttdjf��sdSt|t��rdSt|t��rdSdS)z�Used in concert with _back_transforms_mapping to convert values
        into the appropriate Python objects when retrieving them from
        the list as well as when storing them.Nrrrr�)�
isinstance�str�bytesrWrts r�_extract_recreation_codez&ShareableList._extract_recreation_codesW��
�%�#�u�d�n�!=�>�>�	��1�
��s�
#�
#�	��1�
��u�
%�
%�	��1��1r�rc����|�|��|pd}�fd�|D��}t|���_td�|D�����jksJ�d}dg�_|D]I}||ddkr�jnt|dd���z
}�j�|���J�fd�|D��}tjd�j	zd	�
|��z�jz�jz��}t|d
|����_nt|���_|��t�tjd�j	z�jjd�jg�j�R�tjd	�
|���jj�jg�fd�|D���R�tj�j�jj�jg�fd
�|D���R�tj�j�jj�jg|�R�dSt����_t+tj�j	�jjd�����_dS)Nrmc���g|]v}t|ttf��s�jt	|��n=�jt	|���jt
|���jzdzzfz��wS)r)r�r�r��_types_mapping�type�
_alignmentr��.0�itemrHs  �r�
<listcomp>z*ShareableList.__init__.<locals>.<listcomp>-s��������	&�d�S�%�L�9�9���#�D��J�J�/�/��,�T�$�Z�Z�8���3�t�9�9���+G�!�+K�L�<����rc3�<K�|]}t|��dkV��dS)rrN)r)r��fmts  r�	<genexpr>z)ShareableList.__init__.<locals>.<genexpr>6s,����9�9��s�3�x�x�1�}�9�9�9�9�9�9rrr�sc�:��g|]}��|����Srm)r�r�s  �rr�z*ShareableList.__init__.<locals>.<listcomp>?s4���!�!�!�8<��-�-�d�3�3�!�!�!rrp�T)rIrJc3�p�K�|]0}t|t��r|����n|V��1dSrR)r�r��encode�r��v�_encs  �rr�z)ShareableList.__init__.<locals>.<genexpr>Zs@�����P�P�!�J�q�#�$6�$6�=�!�(�(�4�.�.�.�A�P�P�P�P�P�Prc3�B�K�|]}|����V��dSrR)r�r�s  �rr�z)ShareableList.__init__.<locals>.<genexpr>`s-�����3�3�Q�!�(�(�4�.�.�3�3�3�3�3�3rrr)r�	_list_len�sum�_allocated_offsetsr��int�append�struct�calcsize�_format_size_metainfo�join�_format_packing_metainfo�_format_back_transform_codesr�shmr|�	pack_intor_�_offset_data_start�_offset_packing_formats�_offset_back_transform_codes�list�unpack_from)	rH�sequencer�_formats�offsetr��_recreation_codes�requested_sizer�s	`       @rrPzShareableList.__init__*s������<�8�/��~�2�H�����%�
���H�!��]�]�D�N��9�9��9�9�9�9�9�T�^�K�K�K�K��F�()�c�D�#��
7�
7���S��W��^�^�$�/�/��S��"��X���N���'�.�.�v�6�6�6�6�!�!�!�!�@H�!�!�!��$�_��d�0�0�����!�!�"��-�.��1�2���N�$�D��N�K�K�K�D�H�H�#�D�)�)�D�H����D����d�0�0�������	
�
�)�
�
�
�
�
������!�!�����'�
�Q�P�P�P�x�P�P�P�	
�
�
�
�
���-�����,�
�4�3�3�3�(�3�3�3�	
�
�
�
�
���1�����1�
�$�	
�
�
�
�
�
�!��Y�Y�D�N�&*��"��.��H�L����'�'�D�#�#�#rc�4�|dkr|n	||jz}||jks|jdkrtd���tjd|jj|j|dzz��d}|�d��}|�t��}|S)z>Gets the packing format for a single value stored in the list.r� Requested position out of range.�8srrry)
r��
IndexErrorr�r�r�r_r�rzr{r|)rH�positionr�r��
fmt_as_strs     r�_get_packing_formatz!ShareableList._get_packing_formatss���'�1�}�}�8�8�(�T�^�2K�����&�&�D�N�Q�,>�,>��?�@�@�@�����H�L��(�8�a�<�7�
�
��	

��
�h�h�w�����Z�Z�	�*�*�
��rc���||jks|jdkrtd���tjd|jj|j|z��d}|j|}|S)z9Gets the back transformation function for a single value.rr��b)r�r�r�r�r�r_r��_back_transforms_mapping)rHr��transform_code�transform_functions    r�_get_back_transformz!ShareableList._get_back_transform�ss��
���&�&�D�N�Q�,>�,>��?�@�@�@��+���H�L��-��8�
�
��	
��
"�:�>�J��!�!rc�T�||jks|jdkrtd���tjd|jj|j|dzz|�t����|�	|��}tjd|jj|j
|z|��dS)zvSets the packing format and back transformation code for a
        single value in the list at the specified position.rr�r�rrr�N)r�r�r�r�r�r_r�r�r|r�r�)rHr�r�rur�s     r�!_set_packing_format_and_transformz/ShareableList._set_packing_format_and_transform�s���
���&�&�D�N�Q�,>�,>��?�@�@�@�����H�L��(�8�a�<�7����i�(�(�		
�	
�	
��6�6�u�=�=������H�L��-��8��		
�	
�	
�	
�	
rc�<�|dkr|n	||jz}	|j|j|z}tj|�|��|jj|��\}n#t$rtd���wxYw|�	|��}||��}|S)Nrzindex out of range)
r�r�r�r�r�r�r�r_r�r�)rHr�r�r��back_transforms     r�__getitem__zShareableList.__getitem__�s���'�1�}�}�8�8�(�T�^�2K��	3��,�t�/F�x�/P�P�F��%��(�(��2�2�������D�Q�Q��
�	3�	3�	3��1�2�2�2�	3�����1�1�(�;�;���N�1�����s�A
A�A9c��|dkr|n	||jz}	|j|}|j|z}|�|��}n#t$rt	d���wxYwt|ttf��s|jt|��}|}n�|j|dz|z
}t|t��r|�
t��n|}t|��|krtd���|ddkr|}n|jt|fz}|�|||��tj||jj||��dS)Nrzassignment index out of rangerz(bytes/str item exceeds available storagerr�)r�r�r�r�r�r�r�r�r�r�r�r|rrr�r�r�r�r_)	rHr�ru�item_offsetr��current_format�
new_format�
encoded_value�allocated_lengths	         r�__setitem__zShareableList.__setitem__�s���'�1�}�}�8�8�(�T�^�2K��	>��1�(�;�K��,�{�:�F�!�5�5�h�?�?�N�N���	>�	>�	>��<�=�=�=�	>�����%�#�u��.�.�	��,�T�%�[�[�9�J�!�M�M�#�6�x�!�|�D�{�R��!+�5�#� 6� 6�B�U�\�\�)�4�4�4�<A�
��=�!�!�$4�4�4� �!K�L�L�L��b�!�S�(�(�+�
�
�!�0��5�$�9��
�	
�.�.����	
�	
�	
�
	���T�X�\�6�=�I�I�I�I�Is�,A�Ac�F�t|j|jj���dfS)Nr�rm)rrWr�rrTs rrXzShareableList.__reduce__�s ���t�~�D�H�M�:�:�:�B�>�>rc�N�tjd|jjd��dS)Nrpr)r�r�r�r_rTs r�__len__zShareableList.__len__�s ���!�#�t�x�|�Q�7�7��:�:rc�Z�|jj�dt|���d|jj�d�S)NrZz, name=r[)rWr\r�r�rrTs rr]zShareableList.__repr__�s0���.�)�Q�Q�D��J�J�Q�Q�t�x�}�Q�Q�Q�Qrc�j��d��fd�t�j��D����S)z=The struct packing format used by all currently stored items.r�c3�B�K�|]}��|��V��dSrR)r�)r��irHs  �rr�z'ShareableList.format.<locals>.<genexpr>�sB�����
�
�,-�D�$�$�Q�'�'�
�
�
�
�
�
r)r��ranger�rTs`r�formatzShareableList.format�sK����w�w�
�
�
�
�16�t�~�1F�1F�
�
�
�
�
�	
rc��d|jdzzS)z>The struct packing format used for the items' storage offsets.rpr�r�rTs rr�z#ShareableList._format_size_metainfo�s���d�n�q�(�)�)rc��d|jzS)z>The struct packing format used for the items' packing formats.r�r�rTs rr�z&ShareableList._format_packing_metainfo�s���d�n�$�$rc��d|jzS)z>The struct packing format used for the items' back transforms.r�r�rTs rr�z*ShareableList._format_back_transform_codes�s���T�^�#�#rc��|jdzdzS)Nrrrr�rTs rr�z ShareableList._offset_data_start�s�����"�a�'�'rc�,�|j|jdzS)Nr)r�r�rTs rr�z%ShareableList._offset_packing_formats�s���&��)@��)D�D�Drc�&�|j|jdzzS)Nrr)r�r�rTs rr�z*ShareableList._offset_back_transform_codess���+�d�n�q�.@�@�@rc�:��t�fd�|D����S)zCL.count(value) -> integer -- return number of occurrences of value.c3�$�K�|]
}�|kV��dSrRrm)r��entryrus  �rr�z&ShareableList.count.<locals>.<genexpr>
s'�����4�4�e�5�E�>�4�4�4�4�4�4r)r�)rHrus `r�countzShareableList.counts(����4�4�4�4�t�4�4�4�4�4�4rc�d�t|��D]\}}||kr|cS�t|�d����)zpL.index(value) -> integer -- return first index of value.
        Raises ValueError if the value is not present.z not in this container)�	enumerater)rHrur�r�s    r�indexzShareableList.indexsO�� )����	A�	A�O�H�e���~�~��������?�?�?�@�@�@rrR)&r\rirjrkr��float�boolr�r�rWr�r�r��staticmethodr�rPr�r�r�r�r�rXr�r]rlr�r�r�r�r�r�r�r�r��classmethod�types�GenericAlias�__class_getitem__rmrrrr�s)������*�*�&	�S�
�s��j��U�
�u���
�
�N��J���@�@�.�.���	 � ������\��G�d�G�G�G�G�G�R��� 
"�
"�
"�
�
�
�,���"J�J�J�B?�?�?�;�;�;�R�R�R��
�
��X�
��*�*��X�*��%�%��X�%��$�$��X�$��(�(��X�(�
�E�E��X�E��A�A��X�A�5�5�5�
A�A�A�$��E�$6�7�7���r)rk�__all__�	functoolsrr0r!r<r�rr�rr5r%r&r�r�O_CREATr$r r
rrrr|rrmrr�<module>r�s]����
�O�
-������������	�	�	�	�����
�
�
�
����������7�d�?�?��N�N�N��J�J������J�������
�*�r�y�
 ��������������BE�BE�BE�BE�BE�BE�BE�BE�J
�	�]8�]8�]8�]8�]8�]8�]8�]8�]8�]8r