AlkantarClanX12

Your IP : 3.145.57.5


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

�

c��fj-��"�ddlZddlmZddlZddlZddlZddlZddlZddlm	Z	m
Z
ddlmZdgZ
ejdkrddlZGd�d	e��Zn%Gd
�d	e��Zd�Zd�Ze	jee��Gd
�de��ZGd�de��ZdS)�N)�defaultdict�)�	reduction�assert_spawning)�util�
BufferWrapper�win32c�B�eZdZdZej��Zd�Zd�Zd�Z	dS)�ArenazL
        A shared memory area backed by anonymous memory (Windows).
        c�t�||_td��D]p}dtj��t	|j��fz}t
jd||���}tj��dkrn$|�	���qtd���||_||_|j|jf|_
dS)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/python311/lib64/python3.11/multiprocessing/heap.py�__init__zArena.__init__&s����D�I��3�Z�Z�
G�
G��"�b�i�k�k�4��
�3C�3C�%D�D���i��D�$�7�7�7���'�)�)�Q�.�.��E��	�	�����%�&E�F�F�F��D�I��D�K��9�d�i�0�D�K�K�K�c�.�t|��|jS�N)rr)rs r"�__getstate__zArena.__getstate__5s���D�!�!�!��;�r$c�~�|x\|_|_|_tjd|j|j���|_dS)Nrr)rrrrr)r�states  r"�__setstate__zArena.__setstate__9s7��16�6� �D�I�t�y�4�;��)�B��	�4�9�E�E�E�D�K�K�Kr$N)
�__name__�
__module__�__qualname__�__doc__�tempfile�_RandomNameSequencerr#r'r*�r$r"rrsb������	�	�-��,�.�.��
	1�
	1�
	1�	�	�	�	F�	F�	F�	F�	Fr$rc�B�eZdZdZejdkrdgZngZdd�Zd�ZdS)	rzJ
        A shared memory area backed by a temporary file (POSIX).
        �linuxz/dev/shmrc��||_||_|dkr�tjdt	j��z|�|�����\|_}t	j|��tj	|tj
|jf��t	j|j|��tj|j|j��|_
dS)Nrzpym-%d-)�prefix�dir)r�fdr/�mkstemprr�_choose_dir�unlinkr�Finalizer�	ftruncaterr)rrr7rs    r"r#zArena.__init__Ms����D�I��D�G��R�x�x�!)� 0�%�b�i�k�k�1��)�)�$�/�/�!1�!1�!1�
�����	�$�����
�d�B�H�t�w�j�9�9�9���T�W�d�+�+�+��)�D�G�T�Y�7�7�D�K�K�Kr$c��|jD]-}tj|��}|j|jz|kr|cS�.tj��Sr&)�_dir_candidatesr�statvfs�f_bavail�f_frsizer�get_temp_dir)rr�d�sts    r"r9zArena._choose_dir[sT���)�
�
���Z��]�]���;���,��4�4��H�H�H�5��$�&�&�&r$N)r)	r+r,r-r.�sys�platformr>r#r9r1r$r"rrCs^������	�	��<�7�"�"�)�l�O�O� �O�	8�	8�	8�	8�	'�	'�	'�	'�	'r$c��|jdkrtd���t|jt	j|j��ffS)NrzDArena is unpicklable because forking was enabled when it was created)r7�
ValueError�
rebuild_arenarr�DupFd)�as r"�reduce_arenarLdsF���4�2�:�:��G�H�H�
H��q�v�y��q�t�'<�'<�=�=�=r$c�F�t||�����Sr&)r�detach)r�dupfds  r"rIrIjs���T�5�<�<�>�>�*�*�*r$c�z�eZdZdZdZdZejfd�Ze	d���Z
d�Zd�Zd�Z
d�Zd	�Zd
�Zd�Zd�Zd
�ZdS)�Heap�i@c��tj��|_tj��|_||_g|_i|_i|_	i|_
tt��|_
g|_g|_d|_d|_dS�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__{s����	����
��^�%�%��
���
���
���� "���!���"-�S�!1�!1������%'��!������
�
�
r$c��|dz
}||z|zS)Nrr1)�n�	alignment�masks   r"�_roundupz
Heap._roundup�s���1�}���D��T�E�!�!r$c�.�|�t|j|��tj��}|j|jkr|xjdzc_t
jd|��t|��}|j	�
|��|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�s������s�4�:�t�4�4�d�m�D�D���:��5�5�5��J�J�!�O�J�J��	�6��?�?�?��f�
�
������E�"�"�"��q�&�!�!r$c�\�|j}||jkrdS|j�|��}|rJ�|j|df=|j||f=|j�|��|j|}|�|d|f��|s$|j|=|j	�|��dSdSrT)
r�_DISCARD_FREE_SPACE_LARGER_THANr_�popr\r]r`�remover[rZ)rrqrp�blocks�seqs     r"�_discard_arenazHeap._discard_arena�s�������D�8�8�8��F��'�+�+�E�2�2�����z�� �%���,������0�����E�"�"�"���v�&���
�
�E�1�f�%�&�&�&��	)�� ��(��M� � ��(�(�(�(�(�	)�	)r$c�H�tj|j|��}|t|j��kr|�|��S|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�3����D�M�"�"�"�"��?�?�4�(�(�(��]�1�%�F��"�6�*�C��G�G�I�I�E��
?��$�V�,�d�m�A�.>�$����t�� �%���0�����
�.��r$c���|\}}}	|j||f}|�|��\}}n#t$rYnwxYw	|j||f}|�|��\}}n#t$rYnwxYw|||f}||z
}	|j|�|��n5#t$r(|g|j|<t
j|j|��YnwxYw||j||f<||j||f<dSr&)	r]�_absorb�KeyErrorr\r[ror{�insortrZ)	rr~rqrr��
prev_block�_�
next_blockrps	         r"�_add_free_blockzHeap._add_free_block�sY��$����t�	0��,�e�U�^�<�J��|�|�J�/�/�H�E�1�1���	�	�	��D�	����
	/��-�u�d�m�<�J��l�l�:�.�.�G�A�t�t���	�	�	��D�	����
��t�$������	1���V�$�+�+�E�2�2�2�2���	1�	1�	1�(-�w�D��V�$��M�$�-��0�0�0�0�0�	1����05���e�U�^�,�-2���U�D�M�*�*�*s0�0�
=�=�A)�)
A6�5A6� B%�%/C�Cc���|\}}}|j||f=|j||f=||z
}|j|}|�|��|s"|j|=|j�|��||fSr&)r\r]r[rvrZ)rr~rqrr�rprxs       r"r�zHeap._absorb�s���$����t�� �%���0�����
�.�������v�&���
�
�5�����	)�� ��(��M� � ��(�(�(��d�{�r$c��|\}}}|j|}|�||f��|s|�|��dSdSr&)r_rvry)rr~rqrr�rws      r"�_remove_allocated_blockzHeap._remove_allocated_block�s]��"���u�d��'��.���
�
�u�d�m�$�$�$��	'�����&�&�&�&�&�	'�	'r$c��		|j���}n#t$rYdSwxYw|�|��|�|���Wr&)raru�
IndexErrorr�r��rr~s  r"�_free_pending_blockszHeap._free_pending_blockssq��	0�
��1�5�5�7�7�����
�
�
����
����� � ��'�'�'��(�(��/�/�/�
	0s��
+�+c�(�tj��|jkr9td�tj��|j�����|j�d��s|j�|��dS	|xj	dz
c_	|�
��|�|��|�|��|j�
��dS#|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�;�;�$�-�'�'��6�=�=��I�K�K��
�/�/�0�0�
0��z�!�!�%�(�(�	%�
�%�,�,�U�3�3�3�3�3�
%��
�
��"�
�
��)�)�+�+�+��$�$�U�+�+�+��,�,�U�3�3�3��
�"�"�$�$�$�$�$���
�"�"�$�$�$�$���s
�
AC6�6Dc��|dkr"td�|�����tj|kr"t	d�|�����tj��|jkr|���|j	5|xj
dz
c_
|���|�t|d��|j��}|�|��\}}}||z}||kr|�|||f��|j|�||f��|||fcddd��S#1swxYwYdS)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�8��6�=�=�d�C�C�D�D�D��;�$���� 6� =� =�d� C� C�D�D�D�
�9�;�;�$�-�'�'��M�M�O�O�O�
�Z�	-�	-��O�O�q� �O�O��%�%�'�'�'��=�=��T�1���t��?�?�D�#'�<�<��#5�#5� �U�E�4����I��4����$�$�e�Y��%=�>�>�>��"�5�)�-�-�u�i�.@�A�A�A��5�)�,�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-����	-�	-�	-�	-�	-�	-s�B0E�E�EN)r+r,r-r�rtrmrrlr#�staticmethodrhrrryr�r�r�r�r�r�r�r1r$r"rQrQss��������J�&3�#�,�� �M�����:�"�"��\�"�

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