Your IP : 18.219.158.84


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

�

�Q�f�/���gd�ZddlZddlZddlZddlZddlZddlmZddlmZddlm	Z		ddlm
Z
mZe
ed	��\ZZejj"ZGd
�de�Z
Gd�d
e
�ZGd�de�ZGd�de
�ZGd�de
�ZGd�de�ZGd�de�ZGd�dej2�Zy#e$r	ed��wxYw))�Lock�RLock�	Semaphore�BoundedSemaphore�	Condition�Event�N�)�context)�process)�util)�SemLock�
sem_unlinkz�This platform lacks a functioning sem_open implementation, therefore, the required synchronization primitives needed will not function, see issue 3770.�c�r�eZdZej�Zd�Zed��Zd�Z	d�Z
d�Zd�Zd�Z
ed��Zy	)
r
c��|�tjj�}|j�dk(|_t
jdk(xs|j}td�D]2}	tj||||j�|�x}|_ntd��tjd|jz�|j!�t
jdk7rd�}tj"||�|jj$�`ddlm}	|	|jj$d	�tj*|tj,|jj$fd
��yy#t$rY��!wxYw)N�fork�win32�dzcannot find name for semaphorezcreated semlock with handle %sc�8�|jj�y�N)�_semlock�_after_fork)�objs �B/opt/alt/python312/lib64/python3.12/multiprocessing/synchronize.pyrz%SemLock.__init__.<locals>._after_forkGs�����(�(�*�r	)�register�	semaphorer)�exitpriority)r
�_default_context�get_context�get_start_method�_is_fork_ctx�sys�platform�range�_multiprocessingr
�
_make_namer�FileExistsErrorr�debug�handle�
_make_methods�register_after_fork�name�resource_trackerr�Finalize�_cleanup)
�self�kind�value�maxvalue�ctx�
unlink_now�i�slrrs
          r�__init__zSemLock.__init__2sI���;��*�*�6�6�8�C��0�0�2�f�<����\�\�W�,�A��0A�0A�
��s��A�
�%5�%=�%=��%��4�?�?�+<��& � ��T�]���"�"B�C�C��
�
�3�b�i�i�?�@������<�<�7�"�
+��$�$�T�;�7��=�=���)�
3��T�]�]�'�'��5��M�M�$�� 0� 0�4�=�=�3E�3E�2G�'(�
*�
*��#�
��
�s�).E:�:	F�Fc�8�ddlm}t|�||d�y)Nr	)�
unregisterr)r.r;r)r-r;s  rr0zSemLock._cleanupTs��0��4���4��%rc�p�|jj|_|jj|_yr)r�acquire�release�r1s rr+zSemLock._make_methodsZs$���}�}�,�,����}�}�,�,��rc�6�|jj�Sr)r�	__enter__r?s rrAzSemLock.__enter__^s���}�}�&�&�(�(rc�4�|jj|�Sr)r�__exit__�r1�argss  rrCzSemLock.__exit__as��%�t�}�}�%�%�t�,�,rc�T�tj|�|j}tjdk(r.tj
�j
|j�}n#|jrtd��|j}||j|j|jfS)Nrz�A SemLock created in a fork context is being shared with a process in a spawn context. This is not supported. Please use the same context to create multiprocessing objects and Process.)
r
�assert_spawningrr#r$�get_spawning_popen�duplicate_for_childr*r"�RuntimeErrorr2r4r-)r1r8�hs   r�__getstate__zSemLock.__getstate__ds�������%�
�]�]���<�<�7�"��*�*�,�@�@����K�A�� � �"�$J�K�K��	�	�A��2�7�7�B�K�K����1�1rc��tjj|�|_t	j
d|dz�|j
�d|_y)Nz recreated blocker with handle %rrF)r&r
�_rebuildrrr)r+r"�r1�states  r�__setstate__zSemLock.__setstate__rsD��(�0�0�9�9�5�A��
��
�
�5��a��@�A�����!��rc�|�tj�jd�dttj
���S)N�	semprefix�-)r�current_process�_config�nextr
�_rand�rrr'zSemLock._make_nameys/��!�1�1�3�;�;�K�H��w�}�}�-�/�	/rN)�__name__�
__module__�__qualname__�tempfile�_RandomNameSequencerXr9�staticmethodr0r+rArCrLrQr'rYrrr
r
.sY��(�H�(�(�*�E� *�D�&��&�
-�)�-�2�"��/��/rr
c� �eZdZdd�Zd�Zd�Zy)rc�H�tj|t|t|��y�N�r5)r
r9�	SEMAPHORE�
SEM_VALUE_MAX�r1r3r5s   rr9zSemaphore.__init__�s������y�%��C�Hrc�6�|jj�Sr)r�
_get_valuer?s r�	get_valuezSemaphore.get_value�s���}�}�'�'�)�)rc��	|jj�}d|jj�d|�d�S#t$rd}Y�*wxYw)N�unknown�<�(value=�)>)rrh�	Exception�	__class__rZ�r1r3s  r�__repr__zSemaphore.__repr__�sG��	��M�M�,�,�.�E��$(�>�>�#:�#:�E�B�B���	��E�	�s�9�A�AN�r	)rZr[r\r9rirrrYrrrr�s��I�*�Crrc��eZdZdd�Zd�Zy)rc�@�tj|t|||��yrb�r
r9rdrfs   rr9zBoundedSemaphore.__init__�s������y�%��C�@rc���	|jj�}d|jj�d|�d|jj
�d�S#t$rd}Y�AwxYw)Nrkrlrmz, maxvalue=rn)rrhrorprZr4rqs  rrrzBoundedSemaphore.__repr__�sY��	��M�M�,�,�.�E�����'�'���
�
�0F�0F�H�	H���	��E�	�s�A�A�ANrs�rZr[r\r9rrrYrrrr�s��A�Hrrc��eZdZd�Zd�Zy)rc�@�tj|tdd|��y�Nr	rcrv�r1r5s  rr9z
Lock.__init__�s������y�!�Q�C�8rc���	|jj�rdtj�j}tj�jdk7rg|dtj�jzz
}nB|jj�dk(rd}n"|jj�dkDrd}nd}d	|jj�d
|�d�S#t$rd}Y�*wxYw)N�
MainThread�|r	�Noner�SomeOtherThread�SomeOtherProcessrkrlz(owner=rn)r�_is_minerrUr-�	threading�current_threadrh�_countrorprZ)r1r-s  rrrz
Lock.__repr__�s���	��}�}�%�%�'��.�.�0�5�5���+�+�-�2�2�l�B��C�)�":�":�"<�"A�"A�A�A�D����)�)�+�q�0������%�%�'�!�+�(��)���$(�>�>�#:�#:�D�A�A���	��D�	�s�CC�C-�,C-NrxrYrrrr�s
��9�Brrc��eZdZd�Zd�Zy)rc�@�tj|tdd|��yr{)r
r9�RECURSIVE_MUTEXr|s  rr9zRLock.__init__�s��������1�#�>rc�2�	|jj�r~tj�j}tj�jdk7r$|dtj�jzz
}|jj�}nK|jj�dk(rd\}}n(|jj�dkDrd\}}nd\}}d	|jj�d
|�d|�d�S#t$rd\}}Y�0wxYw)
Nr~rr	)r�rr)r��nonzero)r�r�)rkrkrl�(�, rn)rr�rrUr-r�r�r�rhrorprZ)r1r-�counts   rrrzRLock.__repr__�s���
	/��}�}�%�%�'��.�.�0�5�5���+�+�-�2�2�l�B��C�)�":�":�"<�"A�"A�A�A�D��
�
�,�,�.�����)�)�+�q�0�'���e����%�%�'�!�+�:���e�;���e��"&���!8�!8�$��F�F���	/�.�K�D�%�	/�s�C#D�D�DNrxrYrrrr�s
��?�Grrc�V�eZdZd
d�Zd�Zd�Zd�Zd�Zd�Zd�Z	d
d	�Z
dd
�Zd�Zd
d�Z
y)rNc���|xs|j�|_|jd�|_|jd�|_|jd�|_|j
�y�Nr)r�_lockr�_sleeping_count�_woken_count�_wait_semaphorer+)r1�lockr5s   rr9zCondition.__init__�sS���(�S�Y�Y�[��
�"�}�}�Q�/����M�M�!�,���"�}�}�Q�/������rc��tj|�|j|j|j|j
fSr)r
rGr�r�r�r�r?s rrLzCondition.__getstate__�s:������%��
�
�D�0�0��!�!�4�#7�#7�9�	9rc�Z�|\|_|_|_|_|j	�yr)r�r�r�r�r+rOs  rrQzCondition.__setstate__�s*��49�	2���T�)�	
�	�D�0����rc�6�|jj�Sr)r�rAr?s rrAzCondition.__enter__�s���z�z�#�#�%�%rc�4�|jj|�Sr)r�rCrDs  rrCzCondition.__exit__�s��"�t�z�z�"�"�D�)�)rc�p�|jj|_|jj|_yr)r�r=r>r?s rr+zCondition._make_methods�s$���z�z�)�)����z�z�)�)��rc��	|jjj�|jjj�z
}d|j
j�d|j�d|�d�S#t$rd}Y�7wxYw)Nrkrlr�r�rn)r�rrhr�rorprZr�)r1�num_waiterss  rrrzCondition.__repr__�ss��	$��/�/�8�8�C�C�E��,�,�5�5�@�@�B�C�K��"&���!8�!8�$�*�*�k�R�R���	$�#�K�	$�s�A	A5�5B�Bc�&�|jj�|jjj	�}t|�D]}|jj��	|jjd|�|jj�t|�D]}|jj��S#|jj�t|�D]}|jj��wxYw)NT)	r�r>r�rr�r%r�r=r�)r1�timeoutr�r7s    r�waitzCondition.wait�s���
	
���$�$�&��
�
�#�#�*�*�,���u��A��J�J��� ��		%��'�'�/�/��g�>�
���%�%�'��5�\���
�
�"�"�$�"��
���%�%�'��5�\���
�
�"�"�$�"�s
�*C
�
ADc�8�|jjd�r7|jjd�}|jjd�r�7d}||kr[|jjd�r@|jj	�|dz
}||kr|jjd�r�@|rdt|�D]}|jj��|jjd�r	|jjd�r�yyy)NFrr	)r�r=r�r�r>r%)r1�n�res�sleepersr7s     r�notifyzCondition.notifys������'�'��.��&�&�.�.�u�5�C����'�'��.�
����l�t�3�3�;�;�E�B�� � �(�(�*���M�H���l�t�3�3�;�;�E�B���8�_���!�!�)�)�+�%��&�&�.�.�u�5���&�&�.�.�u�5�rc�D�|jtj��y)N)r�)r�r#�maxsizer?s r�
notify_allzCondition.notify_all/s�����c�k�k��"rc���|�}|r|S|�tj�|z}nd}d}|s<|�|tj�z
}|dkr	|S|j�|�}|s�<|Sr�)�time�	monotonicr�)r1�	predicater��result�endtime�waittimes      r�wait_forzCondition.wait_for2s~�������M����n�n�&��0�G��G��H���"�"�T�^�^�%5�5���q�=���
�
�I�I�h���[�F�
��
rrrs)rZr[r\r9rLrQrArCr+rrr�r�r�r�rYrrrr�s:���9�
�
&�*�*�S�%�.�4#�rrc�8�eZdZd�Zd�Zd�Zd�Zd	d�Zdefd�Z	y)
rc�x�|j|j��|_|jd�|_yr�)rr�_condr�_flagr|s  rr9zEvent.__init__Js(���]�]�3�8�8�:�.��
��]�]�1�%��
rc���|j5|jjd�r$|jj�	ddd�y	ddd�y#1swYyxYw�NFT)r�r�r=r>r?s r�is_setzEvent.is_setNsL��
�Z�Z��z�z�!�!�%�(��
�
�"�"�$��	�	��		�	�Z�Z�s�7A�
A�A c���|j5|jjd�|jj�|jj	�ddd�y#1swYyxYw�NF)r�r�r=r>r�r?s r�setz	Event.setUsE��
�Z�Z��J�J���u�%��J�J��� ��J�J�!�!�#��Z�Z�s�AA&�&A/c�|�|j5|jjd�ddd�y#1swYyxYwr�)r�r�r=r?s r�clearzEvent.clear[s%��
�Z�Z��J�J���u�%��Z�Z�s�2�;Nc�h�|j5|jjd�r|jj�n|jj	|�|jjd�r$|jj�	ddd�y	ddd�y#1swYyxYwr�)r�r�r=r>r�)r1r�s  rr�z
Event.wait_s~��
�Z�Z��z�z�!�!�%�(��
�
�"�"�$��
�
����(��z�z�!�!�%�(��
�
�"�"�$��		�		��		�		�Z�Z�s�BB(�B(�(B1�returnc�|�|j�rdnd}dt|�j�dt|�d�d|�d�S)Nr��unsetrlz at z#x� �>)r��typer\�id)r1�
set_statuss  rrrzEvent.__repr__ks=��"�k�k�m�U��
��4��:�*�*�+�4��4���}�A�j�\��K�Krr)
rZr[r\r9r�r�r�r��strrrrYrrrrHs)��&��$�&�
�L�#�Lrrc��eZdZd	d�Zd�Zd�Zed��Zejd��Zed��Z	e	jd��Z	y)
�BarrierNc��ddl}ddlm}||jd�dz�}|j	�}|j|||||f�d|_d|_y)Nrr	)�
BufferWrapperr7r)�struct�heapr��calcsizerrQ�_stater�)	r1�parties�actionr�r5r�r��wrapper�conds	         rr9zBarrier.__init__tsR���'������ 4�q� 8�9���}�}������7�F�G�T�7�C�D������rc��|\|_|_|_|_|_|jj�j
d�|_y)Nr7)�_parties�_action�_timeoutr��_wrapper�create_memoryview�cast�_arrayrOs  rrQzBarrier.__setstate__}s>��&+�	$�����d�m�	
��T�]��m�m�5�5�7�<�<�S�A��rc�t�|j|j|j|j|jfSr)r�r�r�r�r�r?s rrLzBarrier.__getstate__�s,���
�
�t�|�|�T�]�]��
�
�D�M�M�+�	+rc� �|jdSr��r�r?s rr�zBarrier._state�����{�{�1�~�rc�"�||jd<yr�r�rqs  rr�zBarrier._state��������A�rc� �|jdS�Nr	r�r?s rr�zBarrier._count�r�rc�"�||jd<yr�r�rqs  rr�zBarrier._count�r�r)NN)
rZr[r\r9rQrL�propertyr��setterr�rYrrr�r�rsj���B�
+������]�]���������]�]���rr�)�__all__r�r#r]r&r��r
rrr
r�ImportError�listr%r�rdre�objectrrrrrrr�rYrr�<module>r�s������
�������
4�4�"�%��(�^���� �(�(�6�6�
�N/�f�N/�h
C��
C�&H�y�H�"B�7�B�2G�G�G�4i��i�^%L�F�%L�T"�i���"��k
	�4�
�3�4�4�4�s�B>�>C

?>