Hacked By AnonymousFox

Current Path : /opt/alt/python312/lib64/python3.12/multiprocessing/__pycache__/
Upload File :
Current File : //opt/alt/python312/lib64/python3.12/multiprocessing/__pycache__/shared_memory.cpython-312.pyc

�

�Q�fH���dZddgZddlmZddlZddlZddlZddlZddlZddl	Z	ejdk(rddlZdZnddl
Z
dZd	d
lmZej ej"zZdZerdZnd
Zd�ZGd�d�ZdZGd�d�Zy)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}|dk\sJd��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/python312/lib64/python3.12/multiprocessing/shared_memory.py�_make_filenamer(sX��$�c�*:�&;�;��
A�F��Q�;�3�3�3�;��g�/�/��7�7�D��t�9�-�-�-�-��K�c��eZdZdZdZdZdZdZejZ
dZerdndZ
dd�Zd�Zd	�Zd
�Zed��Zed��Zed
��Zd�Zd�Zy)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�TFc��|dk\std��|r,ttjz|_|dk(rtd��|�(|jtj
zstd��t�r)|�E	t�}	tj||j|j��|_||_
nK|jrd|zn|}tj||j|j��|_||_
	|r"|r tj|j|�tj |j�}|j"}t%j$|j|�|_t-j.|jd��n�|�r"	|�
t�n|}t1j2t0j4t0j6t0j8|dz	d	z|d	z|�}	t1j:�}|t0j<k(rd|�Ktt>j@tjBt>j@�|t0j<��	t1jD|���t%j$d
||��|_t1jD|�||_
n�||_
t1jFt0jHd|�}	t1jJ|t0jHddd�}t1jD|�	t1jL|�}t1jN|�t%j$d
||��|_||_(tS|j&�|_*y#t$rY��+wxYw#t($r|j+��wxYw#t1jD|�wxYw#t1jD|�wxYw#t1jN|�wxYw)
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�/�
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__KsO���q�y��@�A�A��!�B�I�I�-�D�K��q�y� �!W�X�X��<����b�i�i� 7��E�F�F���|��)�+�D�!�#.�#7�#7� � �K�K�!%���$���"&�D�J��%)�%@�%@�s�T�z�d��&�/�/���K�K�������
"��
�
��d��L�L����4�0�������*���}�}��!�Y�Y�t�x�x��6��
�

�%�%�d�j�j�/�B���48�L�� 0�d�I�$�5�5��4�4�����.�.����z�1��z�)�!�
�E�3�*1�*>�*>�*@��*�g�.J�.J�J�#�/�&5�$)�L�L�$&�K�K����$=�$(�$+�$@�$@�	'"�!"�!)� �+�+�E�2�&*�Y�Y�r�4��%K��
��+�+�E�2�!*�D�J��"��
� �/�/��)�)�����
	/�#�1�1���-�-�����E��'�'��.�3�"�3�3�E�:�D��+�+�E�2�!�Y�Y�r�4��>��
���
��t�z�z�*��	��k+�!� �!��$�
����
��
��J �+�+�E�2��,�'�'��.���+�+�E�2�sJ�>1N�A4N!�9A4N?�N?�+'O�(O3�	N�N�!N<�?O�O0�3P
c�D�	|j�y#t$rYywxYw�N)�closer2�rHs r�__del__zSharedMemory.__del__�s"��	��J�J�L���	��	�s��	�c�L�|j|jd|jffS)NF)�	__class__rrJrTs r�
__reduce__zSharedMemory.__reduce__�s)���N�N��	�	���	�	�
�
�	
rc�h�|jj�d|j�d|j�d�S)N�(z, size=�))rW�__name__rrJrTs r�__repr__zSharedMemory.__repr__�s.���.�.�)�)�*�!�D�I�I�=���	�	�{�!�L�Lrc��|jS)z4A memoryview of contents of the shared memory block.)rGrTs r�bufzSharedMemory.buf�s���y�y�rc��|j}tr6|jr*|jjd�r|jdd}|S)z4Unique name that identifies the shared memory block.rrN)r+r%r,�
startswith)rH�
reported_names  rrzSharedMemory.name�s?���
�
�
��$�5�5��z�z�$�$�S�)� $�
�
�1�2��
��rc��|jS)zSize in bytes.)rErTs rrJzSharedMemory.size�s���z�z�rc�2�|j�!|jj�d|_|j�!|jj�d|_tr7|j
dk\r't
j|j
�d|_yyy)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�sq���9�9� ��I�I�����D�I��:�:�!��J�J�����D�J��$�(�(�a�-��H�H�T�X�X���D�H�(�:rc��trM|jr@tj|j�t	j
|jd�yyy)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:���$�*�*��"�"�4�:�:�.��'�'��
�
�O�D�%�:r)NFr)r\�
__module__�__qualname__�__doc__r+r)r1rGr!r"r#r(r%r,rPrUrXr]�propertyr_rrJrSr3�rrrr2s���
B� 
�E�
�C��E��D�
�Y�Y�F��E�%/�T�U��l+�\�
�M��������������Er�utf8c�H�eZdZdZedededededdjdiZ
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#jH�Z%y)#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�J�|jd�jt�S�N�)�rstrip�decode�	_encodingrts rrvzShareableList.<lambda>s�����g�.�5�5�i�@rc�$�|jd�Srx)rzrts rrvzShareableList.<lambda>s
�����g�.rc��yrRrm)�_values rrvzShareableList.<lambda>s��$r)rrr�c��t|ttdjf�syt|t�ryt|t�ryy)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_codes9��
�%�#�u�d�n�n�!=�>��
��s�
#��
��u�
%��r�rc�R�	�|�|���|xsd}|D�cgc]r}t|ttf�s|jt	|�nA|jt	|�|j
t
|�|j
zdzzfz��t}}t
|�|_td�|D��|jk(sJ�d}dg|_	|D]B}||ddk7r|j
n
t|dd�z
}|jj|��D|D�cgc]}|j|���}}tjd|jzdj!|�z|j"z|j$z�}t'|d	|�
�|_nt'|�|_|��,t*�	tj,d|jz|j(j.d|jg|j���tj,dj!�|j(j.|j0g�	fd�|D����tj,|j"|j(j.|j2g�	fd�|D����tj,|j$|j(j.|j4g���yt
|�|_t7tj8|j|j(j.d
��|_	ycc}wcc}w)Nrmrc3�8K�|]}t|�dk���y�w)rrN)r)�.0�fmts  r�	<genexpr>z)ShareableList.__init__.<locals>.<genexpr>6s����9���s�3�x�1�}��s�rr�srp�T)rIrJc3�d�K�|]'}t|t�r|j��n|���)y�wrR)r�r��encode�r��v�_encs  �rr�z)ShareableList.__init__.<locals>.<genexpr>Zs(�����P�x�!�J�q�#�$6�!�(�(�4�.�A�=�x�s�-0c3�@�K�|]}|j�����y�wrR)r�r�s  �rr�z)ShareableList.__init__.<locals>.<genexpr>`s�����3�(�Q�!�(�(�4�.�(���rr)r�r�r��_types_mapping�type�
_alignmentr�	_list_len�sum�_allocated_offsets�int�appendr��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�item�_formats�offsetr��_recreation_codes�requested_sizer�s
         @rrPzShareableList.__init__*s�����<�8�/��~�2�H�%�
�%�D�	&�d�S�%�L�9��#�#�D��J�/��,�,�T�$�Z�8����3�t�9����+G�!�+K�L�<���
%�

��!��]�D�N��9��9�9�T�^�^�K�K�K��F�()�c�D�#����S��W��^�$�/�/��S��"�X��N���'�'�.�.�v�6� �AI�!�@H���-�-�d�3��
�!�$�_�_��d�0�0�0�����!�"��-�-�.��1�1�2��N�$�D��N�K�D�H�#�D�)�D�H����D�����d�0�0�0����������	
�
�)�)�
�
�������!�������'�'�
�Q�x�P�	
�
����-�-�������,�,�
�4�(�3�	
�
����1�1�������1�1�
�$�	
�!��Y�D�N�&*��"�"��.�.��H�H�L�L���'�D�#��}��$!s�A7L�L$c�L�|dk\r|n||jz}||jk\s|jdkrtd��tjd|jj
|j|dzz�d}|jd�}|jt�}|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�(�T�^�^�2K������&�D�N�N�Q�,>��?�@�@������H�H�L�L��(�(�8�a�<�7�
��	

��
�h�h�w����Z�Z�	�*�
��rc���||jk\s|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�sv��
����&�D�N�N�Q�,>��?�@�@��+�+���H�H�L�L��-�-��8�
��	
��
"�:�:�>�J��!�!rc��||jk\s|jdkrtd��tjd|jj
|j|dzz|jt��|j|�}tjd|jj
|j|z|�y)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�N�Q�,>��?�@�@������H�H�L�L��(�(�8�a�<�7����i�(�		
��6�6�u�=�������H�H�L�L��-�-��8��		
rc�F�|dk\r|n||jz}	|j|j|z}tj|j|�|jj|�\}|j|�}||�}|S#t$rtd��wxYw)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�(�T�^�^�2K��	3��,�,�t�/F�/F�x�/P�P�F��%�%��(�(��2��������D�Q��1�1�(�;���1������
�	3��1�2�2�	3�s�AB�B c��|dk\r|n||jz}	|j|}|j|z}|j|�}t|ttf�s|jt|�}|}nw|j|dz|z
}t|t�r|jt�n|}t|�|kDrtd��|ddk(r|}n|jt|fz}|j|||�tj ||j"j$||�y#t$rt	d��wxYw)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__�sO��'�1�}�8�(�T�^�^�2K��	>��1�1�(�;�K��,�,�{�:�F�!�5�5�h�?�N��%�#�u��.��,�,�T�%�[�9�J�!�M�#�6�6�x�!�|�D�{�R��!+�5�#� 6�#�\�\�)�4�<A�
��=�!�$4�4� �!K�L�L��b�!�S�(�+�
�!�0�0��5�$�9��
�	
�.�.����	
�
	����T�X�X�\�\�6�=�I��3�	>��<�=�=�	>�s�/D/�/Ec�\�t|j|jj��dfS)Nr�rm)rrWr�rrTs rrXzShareableList.__reduce__�s ���t�~�~�D�H�H�M�M�:�B�>�>rc�^�tjd|jjd�dS)Nrpr)r�r�r�r_rTs r�__len__zShareableList.__len__�s$���!�!�#�t�x�x�|�|�Q�7��:�:rc�z�|jj�dt|��d|jj�d�S)NrZz, name=r[)rWr\r�r�rrTs rr]zShareableList.__repr__�s3���.�.�)�)�*�!�D��J�<�w�t�x�x�}�}�>O�q�Q�Qrc�^��dj�fd�t�j�D��S)z=The struct packing format used by all currently stored items.r�c3�@�K�|]}�j|����y�wrR)r�)r��irHs  �rr�z'ShareableList.format.<locals>.<genexpr>�s!�����
�1F�A�D�$�$�Q�'�1F�r�)r��ranger�rTs`r�formatzShareableList.format�s,����w�w�
�16�t�~�~�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�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�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�n�q�.@�@�@rc�,��t�fd�|D��S)zCL.count(value) -> integer -- return number of occurrences of value.c3�(�K�|]	}�|k(���y�wrRrm)r��entryrus  �rr�z&ShareableList.count.<locals>.<genexpr>
s�����4�t�e�5�E�>�t�s�)r�)rHrus `r�countzShareableList.counts����4�t�4�4�4rc�V�t|�D]\}}||k(s�|cSt|�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s7�� )���O�H�e���~��� /���y�(>�?�@�@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�sI��*�&	�S�
�s��j��U�
�u����
�
�N��J��@�.��	 ������G�d�G�R� 
"�
�,�"J�B?�;�R��
��
��*��*��%��%��$��$��(��(�
�E��E��A��A�5�
A�$�E�$6�$6�7�r)rk�__all__�	functoolsrr0r!r<r�rr�rr5r%r&r�r�O_CREATr$r r
rrrr|rrmrr�<module>r�s����
�O�
-����	��
����7�7�d�?���J���J��
�*�*�r�y�y�
 ����������BE�BE�J
�	�]8�]8r

Hacked By AnonymousFox1.0, Coded By AnonymousFox