Your IP : 3.21.98.162


Current Path : /opt/alt/python313/lib64/python3.13/multiprocessing/__pycache__/
Upload File :
Current File : //opt/alt/python313/lib64/python3.13/multiprocessing/__pycache__/shared_memory.cpython-313.pyc

�

*}g�I���SrSS/rSSKJr SSKrSSKrSSKrSSKrSSKrSSK	r	\RS:XaSSKrSrOSSK
r
SrS	S
KJr \R \R"-rSr\(aSrOS
rSr"SS5rSr"SS5rg)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��[[[5-
S-nUS:�dS5e[[R"U5-n[U5[::deU$)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/python313/lib64/python3.13/multiprocessing/shared_memory.py�_make_filenamer(sX��$�c�*:�&;�;��
A�F��Q�;�3�3�3�;��g�/�/��7�7�D��t�9�-�-�-�-��K�c��\rSrSrSrSrSrSrSr\	RrSr\
(aSOSrSrSSS.S	jjrS
rSrSr\S
5r\S5r\S5rSrSrSrg)r�2a�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�TF)�trackc��US:�d[S5eU(a-[[R-UlUS:Xa[S5eUc-UR[R
-(d[S5eX@l[(GaHUcB[5n[R"UURURS9UlXlOMUR(aSU-OUn[R"UURURS9UlXlU(a(U(a![R "URU5 [R""UR5nUR$n[&R&"URU5UlUR(a![.R0"URS5 GO�U(Ga'Uc
[5OUn[2R4"[2R6[2R8[2R:US-	S	-US	-U5n[2R<"5nU[2R>:XahUbL[[@RB[RD"[@RB5U[2R>5e[2RF"U5 M�[&R&"S
X6S9Ul[2RF"U5 X`lO�Xl[2RH"[2RJSU5n[2RL"U[2RJSSS5n	[2RF"U5 [2RN"U	5n[2RP"U	5 [&R&"S
X1S9UlX0l)[UUR(5Ul+g![a GMUf=f![*a UR-5 ef=f![2RF"U5 f=f![2RF"U5 f=f![2RP"U	5 f=f)
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�_track�
_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�sizer�stats�	temp_name�h_map�last_error_code�p_bufs
          r�__init__�SharedMemory.__init__LsP���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�!%���$���"&�J��%)�%@�%@�s�T�z�d��&�/�/���K�K�������
"�
�
��d��L�L����4�0�������*���}�}��!�Y�Y�t�x�x��6��
��{�{� �)�)�$�*�*�o�F����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�!*�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�/O�BO$�7A8P�P�,(P�+P9�
O!� O!�$P�P�P6�9Qc�F�UR5 g![a gf=f�N)�closer5�rKs r�__del__�SharedMemory.__del__�s"��	��J�J�L���	��	�s��
 � c�L�URURSUR44$)NF)�	__class__rrMrXs r�
__reduce__�SharedMemory.__reduce__�s)���N�N��	�	���	�	�
�
�	
rc�j�URRSUR<SURS3$)N�(z, size=�))r\�__name__rrMrXs r�__repr__�SharedMemory.__repr__�s.���.�.�)�)�*�!�D�I�I�=���	�	�{�!�L�Lrc��UR$)z4A memoryview of contents of the shared memory block.)rJrXs r�buf�SharedMemory.buf�s���y�y�rc��URn[(a@UR(a/URRS5(aURSSnU$)z4Unique name that identifies the shared memory block.rrN)r.r(r/�
startswith)rK�
reported_names  rr�SharedMemory.name�sD���
�
�
��:�$�5�5��z�z�$�$�S�)�)� $�
�
�1�2��
��rc��UR$)zSize in bytes.)rHrXs rrM�SharedMemory.size�s���z�z�rc�D�URb!URR5 SUlURb!URR5 SUl[(a9UR
S:�a([R"UR
5 SUlggg)zcCloses access to the shared memory from this instance but does
not destroy the shared memory block.Nrr)rJ�releaser4rWr(r,r#rXs rrW�SharedMemory.close�ss���9�9� ��I�I�����D�I��:�:�!��J�J�����D�J��:�$�(�(�a�-��H�H�T�X�X���D�H�(�:rc���[(afUR(aT[R"UR5 UR(a"[
R"URS5 gggg)a�Requests that the underlying shared memory block be destroyed.

Unlink should be called once (and only once) across all handles
which have access to the shared memory block, even if these
handles belong to different processes. Closing and unlinking may
happen in any order, but trying to access data inside a shared
memory block after unlinking may result in memory errors,
depending on platform.

This method has no effect on Windows, where the only way to
delete a shared memory block is to close all handles.rN)r(r.r)�
shm_unlinkr'r�
unregisterrXs rr6�SharedMemory.unlink�sH���:�$�*�*��"�"�4�:�:�.��{�{� �+�+�D�J�J��H��%�:r)rJr,r%r4r.rHr')NFr)rb�
__module__�__qualname__�__firstlineno__�__doc__r.r,r4rJr#r$r%r+r(r/r'rSrYr]rc�propertyrfrrMrWr6�__static_attributes__�rrrr2s���
B� 
�E�
�C��E��D�
�Y�Y�F��E�%/�T�U��
�F�m+��m+�^�
�M��������������Ir�utf8c�T�\rSrSrSr\S\S\S\S\	SSRS0rS	rS
SSS
S.r
\S5rS$SS.SjjrSrSrSrSrSrSrSrSr\S5r\S5r\S5r\S5r\S5r\S5r\S 5r S!r!S"r"\#"\$RJ5r&S#r'g)%riaqPattern 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��U$rVr{��values r�<lambda>�ShareableList.<lambda> s��rc�J�URS5R[5$�N�)�rstrip�decode�	_encodingr�s rr�r�!s�����g�.�5�5�i�@rc�$�URS5$r�)r�r�s rr�r�"s
�����g�.rc��grVr{)�_values rr�r�#s��$r)rrr�c��[U[[SR45(dg[U[5(ag[U[5(agg)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�bytesr\r�s r�_extract_recreation_code�&ShareableList._extract_recreation_code&sB��
�%�#�u�d�n�n�!=�>�>��
��s�
#�
#��
��u�
%�
%��r�rc�^	�UbUGb�U=(d SnUVs/sHxn[U[[45(dUR[	U5OAUR[	U5UR
[
U5UR
-S--4-PMz nn[
U5Ul[SU55UR:XdeSnS/Ul	UHCnXVSS:waUR
O
[USS5-
nURRU5 ME UVs/sHo0RU5PM nn[R"SUR-SR!U5-UR"-UR$-5n['US	US
9UlO['U5UlUGb2[*m	[R,"SUR-UR(R.SUR/URQ76 [R,"SR!W5UR(R.UR0/U	4SjU5Q76 [R,"UR"UR(R.UR2/U	4SjU5Q76 [R,"UR$UR(R.UR4/WQ76 g[
U5Ul[7[R8"URUR(R.S
55Ul	gs snfs snf)Nr{rc3�># �UHn[U5S:*v� M g7f)r�N)r)�.0�fmts  r�	<genexpr>�)ShareableList.__init__.<locals>.<genexpr>@s���9���s�3�x�1�}��s�rr�sr~�T)rLrMc3�t># �UH-n[U[5(aURT5OUv� M/ g7frV)r�r��encode�r��v�_encs  �rr�r�ds*����P�x�!�J�q�#�$6�$6�!�(�(�4�.�A�=�x�s�58c3�D># �UHoRT5v� M g7frV)r�r�s  �rr�r�js����3�(�Q�(�(�4�.�.�(�s� r�)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_intorf�_offset_data_start�_offset_packing_formats�_offset_back_transform_codes�list�unpack_from)
rK�sequencer�item�_formats�offsetr��_recreation_codes�requested_sizer�s
         @rrS�ShareableList.__init__4s�����<�8�/��~�2�H�%�
�%�D�	&�d�S�%�L�9�9��#�#�D��J�/��,�,�T�$�Z�8����3�t�9����+G�!�+K�L�<���
%�

��!��]�D�N��9��9�9�T�^�^�K�K�K��F�()�c�D�#�����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�A?L9�"L>c�P�US:�aUO
XR-nXR:�dURS:a[S5e[R"SURR
URUS--5SnURS5nUR[5nU$)z>Gets the packing format for a single value stored in the list.r� Requested position out of range.�8sr�r�)
r��
IndexErrorr�r�r�rfr�r�r�r�)rK�positionr�r��
fmt_as_strs     r�_get_packing_format�!ShareableList._get_packing_format}s���'�1�}�8�(�^�^�2K�����&�D�N�N�Q�,>��?�@�@������H�H�L�L��(�(�8�a�<�7�
��	

��
�h�h�w����Z�Z�	�*�
��rc���XR:�dURS:a[S5e[R"SURR
URU-5SnURUnU$)z9Gets the back transformation function for a single value.rr��b)r�r�r�r�r�rfr��_back_transforms_mapping)rKr��transform_code�transform_functions    r�_get_back_transform�!ShareableList._get_back_transform�st��
���&�D�N�N�Q�,>��?�@�@��+�+���H�H�L�L��-�-��8�
��	
��
"�:�:�>�J��!�!rc��XR:�dURS:a[S5e[R"SURR
URUS--UR[55 URU5n[R"SURR
URU-U5 g)znSets the packing format and back transformation code for a
single value in the list at the specified position.rr�r�r�r�N)r�r�r�r�r�rfr�r�r�r�r�)rKr�r�r�r�s     r�!_set_packing_format_and_transform�/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�J�US:�aUO
XR-nURURU-n[R"URU5URRU5unURU5nU"U5nU$![a [S5ef=f)Nrzindex out of range)
r�r�r�r�r�r�r�rfr�r�)rKr�r�r��back_transforms     r�__getitem__�ShareableList.__getitem__�s���'�1�}�8�(�^�^�2K��	3��,�,�t�/F�/F�x�/P�P�F��%�%��(�(��2��������D�Q��1�1�(�;���1������
�	3��1�2�2�	3�s�AB�B"c��US:�aUO
XR-nURUnURU-nURU5n[U[[45(dUR[U5nUnO~URUS-U-
n[U[5(aUR[5OUn[U5U:�a[S5eUSS:XaUnOUR[U4-nURUUU5 [R "X`R"R$XG5 g![a [	S5ef=f)Nrzassignment index out of rangerz(bytes/str item exceeds available storagerr�)r�r�r�r�r�r�r�r�r�r�r�r�rr!r�r�r�r�rf)	rKr�r��item_offsetr��current_format�
new_format�
encoded_value�allocated_lengths	         r�__setitem__�ShareableList.__setitem__�sO��'�1�}�8�(�^�^�2K��	>��1�1�(�;�K��,�,�{�:�F�!�5�5�h�?�N��%�#�u��.�.��,�,�T�%�[�9�J�!�M�#�6�6�x�!�|�D�{�R��!+�5�#� 6� 6�#�\�\�)�4�<A�
��=�!�$4�4� �!K�L�L��b�!�S�(�+�
�!�0�0��5�$�9��
�	
�.�.����	
�
	����X�X�\�\�6�I��3�	>��<�=�=�	>�s�/D:�:Ec�V�[URURRS9S4$)Nr�r{)rr\r�rrXs rr]�ShareableList.__reduce__�s ���t�~�~�D�H�H�M�M�:�B�>�>rc�`�[R"SURRS5S$)Nr~r)r�r�r�rfrXs r�__len__�ShareableList.__len__�s$���!�!�#�t�x�x�|�|�Q�7��:�:rc�|�URRS[U5SURR<S3$)Nr`z, name=ra)r\rbr�r�rrXs rrc�ShareableList.__repr__�s3���.�.�)�)�*�!�D��J�<�w�t�x�x�}�}�>O�q�Q�Qrc�`^�SRU4Sj[TR555$)z=The struct packing format used by all currently stored items.r�c3�F># �UHnTRU5v� M g7frV)r�)r��irKs  �rr��'ShareableList.format.<locals>.<genexpr>�s#����
�1F�A�D�$�$�Q�'�'�1F�s�!)r��ranger�rXs`r�format�ShareableList.format�s,����w�w�
�16�t�~�~�1F�
�
�	
rc�&�SURS--$)z>The struct packing format used for the items' storage offsets.r~r�r�rXs rr��#ShareableList._format_size_metainfo�s���d�n�n�q�(�)�)rc� �SUR-$)z>The struct packing format used for the items' packing formats.r�r�rXs rr��&ShareableList._format_packing_metainfo�s���d�n�n�$�$rc� �SUR-$)z>The struct packing format used for the items' back transforms.r�r�rXs rr��*ShareableList._format_back_transform_codes�s���T�^�^�#�#rc�&�URS-S-$)Nrr�r�rXs rr�� ShareableList._offset_data_starts������"�a�'�'rc�:�URURS-$)Nr)r�r�rXs rr��%ShareableList._offset_packing_formats	s���&�&��)@�)@��)D�D�Drc�:�URURS--$)Nr�)r�r�rXs rr��*ShareableList._offset_back_transform_codes
s���+�+�d�n�n�q�.@�@�@rc�.^�[U4SjU55$)zCL.count(value) -> integer -- return number of occurrences of value.c3�.># �UH
nTU:Hv� M g7frVr{)r��entryr�s  �rr��&ShareableList.count.<locals>.<genexpr>s����4�t�e�5�E�>�t�s�)r�)rKr�s `r�count�ShareableList.counts����4�t�4�4�4rc�Z�[U5Hup#X:XdMUs $ [U<S35e)zhL.index(value) -> integer -- return first index of value.
Raises ValueError if the value is not present.z not in this container)�	enumerater!)rKr�r�r�s    r�index�ShareableList.indexs3�� )���O�H��~��� /���y�(>�?�@�@r)r�r�r�rV)(rbrurvrwrxr��float�boolr�r�r\r�r�r��staticmethodr�rSr�r�r�r�r�r]r�rcryr�r�r�r�r�r�r�r�r�classmethod�types�GenericAlias�__class_getitem__rzr{rrrrsI��*�&	�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)rx�__all__�	functoolsrr3r#r?r�rrrr8r(r)r�r�O_CREATr&r"r
rrrr�rr{rr�<module>rs����
�O�
-����	��
����7�7�d�?���J���J��
�*�*�r�y�y�
 ����������LI�LI�^
�	�]8�]8r

?>