Your IP : 18.118.28.160


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

�

�Q�fj-���ddlZddlmZddlZddlZddlZddlZddlZddlm	Z	m
Z
ddlmZdgZ
ejdk(rddlZGd�d	e�Zn$Gd
�d	e�Zd�Zd�Ze	j(ee�Gd
�de�ZGd�de�Zy)�N)�defaultdict�)�	reduction�assert_spawning)�util�
BufferWrapper�win32c�D�eZdZdZej
�Zd�Zd�Zd�Z	y)�ArenazL
        A shared memory area backed by anonymous memory (Windows).
        c�x�||_td�D]o}dtj�t	|j
�fz}t
jd||��}tj�dk(rn|j��qtd��||_||_|j|jf|_
y)N�dz	pym-%d-%s�����tagnamerzCannot find name for new mmap)�size�range�os�getpid�next�_rand�mmap�_winapi�GetLastError�close�FileExistsError�name�buffer�_state)�selfr�ir�bufs     �;/opt/alt/python312/lib64/python3.12/multiprocessing/heap.py�__init__zArena.__init__&s����D�I��3�Z��"�b�i�i�k�4��
�
�3C�%D�D���i�i��D�$�7���'�'�)�Q�.���	�	��
 �&�&E�F�F��D�I��D�K��9�9�d�i�i�0�D�K�c�0�t|�|jS�N)rr)rs r"�__getstate__zArena.__getstate__5s���D�!��;�;�r$c��|x\|_|_|_tjd|j|j��|_y)Nrr)rrrrr)r�states  r"�__setstate__zArena.__setstate__9s3��16�6� �D�I�t�y�4�;��)�)�B��	�	�4�9�9�E�D�Kr$N)
�__name__�
__module__�__qualname__�__doc__�tempfile�_RandomNameSequencerr#r'r*�r$r"rrs)��	�-��,�,�.��
	1�	�	Fr$rc�H�eZdZdZej
dk(rdgZngZdd�Zd�Zy)rzJ
        A shared memory area backed by a temporary file (POSIX).
        �linuxz/dev/shmc���||_||_|dk(r�tjdt	j
�z|j
|���\|_}t	j|�tj|tj|jf�t	j|j|�tj|j|j�|_
y)Nrzpym-%d-)�prefix�dir)r�fdr/�mkstemprr�_choose_dir�unlinkr�Finalizer�	ftruncaterr)rrr7rs    r"r#zArena.__init__Ms����D�I��D�G��R�x�!)� 0� 0�%�b�i�i�k�1��)�)�$�/�!1�
�����	�	�$���
�
�d�B�H�H�t�w�w�j�9����T�W�W�d�+��)�)�D�G�G�T�Y�Y�7�D�Kr$c��|jD]7}tj|�}|j|jz|k\s�5|cStj�Sr&)�_dir_candidatesr�statvfs�f_bavail�f_frsizer�get_temp_dir)rr�d�sts    r"r9zArena._choose_dir[sL���)�)���Z�Z��]���;�;����,��4��H�*��$�$�&�&r$N)r)	r+r,r-r.�sys�platformr>r#r9r1r$r"rrCs+��	��<�<�7�"�)�l�O� �O�	8�	'r$c��|jdk(rtd��t|jt	j
|j�ffS)NrzDArena is unpicklable because forking was enabled when it was created)r7�
ValueError�
rebuild_arenarr�DupFd)�as r"�reduce_arenarLdsC���4�4�2�:��G�H�
H��q�v�v�y���q�t�t�'<�=�=�=r$c�6�t||j��Sr&)r�detach)r�dupfds  r"rIrIjs���T�5�<�<�>�*�*r$c�|�eZdZdZdZdZejfd�Ze	d��Z
d�Zd�Zd�Z
d�Zd	�Zd
�Zd�Zd�Zd
�Zy)�Heap�i@c��tj�|_tj�|_||_g|_i|_i|_	i|_
tt�|_
g|_g|_d|_d|_y�Nr)rr�_lastpid�	threading�Lock�_lock�_size�_lengths�_len_to_seq�_start_to_block�_stop_to_blockr�set�_allocated_blocks�_arenas�_pending_free_blocks�
_n_mallocs�_n_frees)rrs  r"r#z
Heap.__init__{sy���	�	���
��^�^�%��
���
���
���� "���!���"-�S�!1������%'��!������
r$c��|dz
}||z|zS)Nrr1)�n�	alignment�masks   r"�_roundupz
Heap._roundup�s���1�}���D��T�E�!�!r$c�H�|jt|j|�tj�}|j|j
kr|xjdzc_t
jd|�t|�}|jj|�|d|fS)N�z"allocating a new mmap of length %dr)rh�maxrYr�PAGESIZE�_DOUBLE_ARENA_SIZE_UNTILr�inforr`�append)rr�length�arenas    r"�
_new_arenazHeap._new_arena�sy�����s�4�:�:�t�4�d�m�m�D���:�:��5�5�5��J�J�!�O�J��	�	�6��?��f�
�������E�"��q�&�!�!r$c��|j}||jkry|jj|�}|j|df=|j
||f=|jj|�|j|}|j|d|f�|s)|j|=|jj|�yyrT)
r�_DISCARD_FREE_SPACE_LARGER_THANr_�popr\r]r`�remover[rZ)rrqrp�blocks�seqs     r"�_discard_arenazHeap._discard_arena�s��������D�8�8�8���'�'�+�+�E�2��� � �%���,�������0������E�"����v�&���
�
�E�1�f�%�&��� � ��(��M�M� � ��(�r$c�t�tj|j|�}|t|j�k(r|j	|�S|j|}|j
|}|j
�}|s|j
|=|j|=|\}}}|j||f=|j||f=|Sr&)	�bisect�bisect_leftrZ�lenrrr[rur\r])	rrr rprx�blockrq�start�stops	         r"�_malloczHeap._malloc�s������t�}�}�d�3����D�M�M�"�"��?�?�4�(�(��]�]�1�%�F��"�"�6�*�C��G�G�I�E���$�$�V�,�d�m�m�A�.>�$����t�� � �%���0������
�.��r$c��|\}}}	|j||f}|j|�\}}	|j||f}|j|�\}}|||f}||z
}	|j|j|�||j||f<||j||f<y#t$rY�}wxYw#t$rY�fwxYw#t$r3|g|j|<t
j|j|�Y�|wxYwr&)	r]�_absorb�KeyErrorr\r[ror{�insortrZ)	rr~rqrr��
prev_block�_�
next_blockrps	         r"�_add_free_blockzHeap._add_free_block�s ��$����t�	0��,�,�e�U�^�<�J��|�|�J�/�H�E�1�	/��-�-�u�d�m�<�J��l�l�:�.�G�A�t���t�$������	1����V�$�+�+�E�2�
05����e�U�^�,�-2����U�D�M�*��-�	��	���	��	���	1�(-�w�D���V�$��M�M�$�-�-��0�	1�s4�B�B.�B=�	B+�*B+�.	B:�9B:�=9C9�8C9c���|\}}}|j||f=|j||f=||z
}|j|}|j|�|s(|j|=|jj|�||fSr&)r\r]r[rvrZ)rr~rqrr�rprxs       r"r�zHeap._absorb�s���$����t�� � �%���0������
�.��������v�&���
�
�5���� � ��(��M�M� � ��(��d�{�r$c�|�|\}}}|j|}|j||f�|s|j|�yyr&)r_rvry)rr~rqrr�rws      r"�_remove_allocated_blockzHeap._remove_allocated_block�sD��"���u�d��'�'��.���
�
�u�d�m�$������&�r$c��		|jj�}|j|�|j	|��>#t$rYywxYwr&)raru�
IndexErrorr�r��rr~s  r"�_free_pending_blockszHeap._free_pending_blockssU���
��1�1�5�5�7��
� � ��'��(�(��/�
���
��
�s�A�	A�Ac�$�tj�|jk7r7tdj	tj�|j���|j
j
d�s|jj|�y	|xjdz
c_	|j�|j|�|j|�|j
j�y#|j
j�wxYw)Nz$My pid ({0:n}) is not last pid {1:n}Fr)rrrUrH�formatrX�acquirerarorcr�r�r��releaser�s  r"�freez	Heap.frees����9�9�;�$�-�-�'��6�=�=��I�I�K��
�
�/�0�
0��z�z�!�!�%�(�
�%�%�,�,�U�3�
%��
�
��"�
��)�)�+��$�$�U�+��,�,�U�3��
�
�"�"�$���
�
�"�"�$�s
�AC3�3Dc��|dkrtdj|���tj|krt	dj|���tj�|jk7r|j�|j5|xjdz
c_
|j�|jt|d�|j�}|j|�\}}}||z}||kr|j!|||f�|j"|j%||f�|||fcddd�S#1swYyxYw)Nr�Size {0:n} out of range�Size {0:n} too larger)rHr�rE�maxsize�
OverflowErrorrrrUr#rXrbr�rhrk�
_alignmentr�r�r_�add)rrrqrr��	real_stops      r"�malloczHeap.malloc(s
���!�8��6�=�=�d�C�D�D��;�;�$��� 6� =� =�d� C�D�D�
�9�9�;�$�-�-�'��M�M�O�
�Z�Z��O�O�q� �O��%�%�'��=�=��T�1��t���?�D�#'�<�<��#5� �U�E�4����I��4���$�$�e�Y��%=�>��"�"�5�)�-�-�u�i�.@�A��5�)�,�	-�	-�Z�Z�s
�
B#D7�7EN)r+r,r-r�rtrmrrlr#�staticmethodrhrrryr�r�r�r�r�r�r�r1r$r"rQrQssb���J�&3�#�,�� �M�M��:�"��"�

"�)�$�"3�<
�'�0�%�8-r$rQc�&�eZdZe�Zd�Zd�Zy)rc�N�|dkrtdj|���tj|krt	dj|���t
jj|�}||f|_tj|t
jj|f��y)Nrr�r�)�args)rHr�rEr�r�r�_heapr�rrr;r�)rrr~s   r"r#zBufferWrapper.__init__Fs����!�8��6�=�=�d�C�D�D��;�;�$��� 6� =� =�d� C�D�D��#�#�*�*�4�0���d�m����
�
�d�M�/�/�4�4�E�8�Dr$c�^�|j\\}}}}t|j�|||zSr&)r�
memoryviewr)rrqrr�rs     r"�create_memoryviewzBufferWrapper.create_memoryviewOs1��%)�[�[�"����t�d��%�,�,�'��e�D�j�9�9r$N)r+r,r-rQr�r#r�r1r$r"rrBs���F�E�E�:r$)r{�collectionsrrrrEr/rV�contextrr�r�__all__rFr�objectrrLrI�registerrQrr1r$r"�<module>r�s����#��	�
���/���
���<�<�7���F��F�H'��'�B>�+��I���u�l�+�I-�6�I-�^:�F�:r$

?>