AlkantarClanX12

Your IP : 3.133.138.129


Current Path : /proc/thread-self/root/lib64/python3.8/multiprocessing/__pycache__/
Upload File :
Current File : //proc/thread-self/root/lib64/python3.8/multiprocessing/__pycache__/synchronize.cpython-38.pyc

U

e5dZ-�@s,ddddddgZddlZddlZddlZddlZddlZdd	lmZdd
lmZddlm	Z	zddlm
Z
mZWnek
r�ed
��YnXe
ed��\ZZej
jZGdd�de�Z
Gdd�de
�ZGdd�de�ZGdd�de
�ZGdd�de
�ZGdd�de�ZGdd�de�ZGdd�dej�ZdS)�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@s\eZdZe��Zdd�Zedd��Zdd�Z	dd�Z
d	d
�Zdd�Zd
d�Z
edd��ZdS)rc	Cs�|dkrtj��}|��}tjdkp*|dk}td�D]>}z t�||||�	�|�}|_
Wntk
rlYq4Xq|q4td��t�
d|j�|��tjdkr�dd�}	t�||	�|j
jdk	r�dd	lm}
|
|j
jd
�tj|tj|j
jfdd�dS)
N�win32�fork�dzcannot find name for semaphorezcreated semlock with handle %scSs|j��dS�N)�_semlock�_after_fork)�obj�r�3/usr/lib64/python3.8/multiprocessing/synchronize.pyrGsz%SemLock.__init__.<locals>._after_forkr)�register�	semaphorer)Zexitpriority)r	Z_default_contextZget_contextZget_start_method�sys�platform�range�_multiprocessingr�
_make_namer�FileExistsErrorr�debug�handle�
_make_methodsZregister_after_fork�name�resource_trackerrZFinalize�_cleanup)�self�kind�value�maxvalue�ctxr#Z
unlink_now�i�slrrrrr�__init__2s8
�
�zSemLock.__init__cCs"ddlm}t|�||d�dS)Nr)�
unregisterr)r$r.r
)r#r.rrrr%TszSemLock._cleanupcCs|jj|_|jj|_dSr)r�acquire�release�r&rrrr"Zs
zSemLock._make_methodscCs
|j��Sr)r�	__enter__r1rrrr2^szSemLock.__enter__cGs|jj|�Sr)r�__exit__�r&�argsrrrr3aszSemLock.__exit__cCsDt�|�|j}tjdkr,t���|j�}n|j}||j|j	|j
fS)Nr)r	�assert_spawningrrrZget_spawning_popenZduplicate_for_childr!r'r)r#)r&r,�hrrr�__getstate__ds

zSemLock.__getstate__cCs,tjj|�|_t�d|d�|��dS)Nz recreated blocker with handle %rr)rrZ_rebuildrrr r"�r&�staterrr�__setstate__mszSemLock.__setstate__cCsdt��jdttj�fS)Nz%s-%sZ	semprefix)r
�current_processZ_config�nextr�_randrrrrrrs�zSemLock._make_nameN)�__name__�
__module__�__qualname__�tempfileZ_RandomNameSequencer>r-�staticmethodr%r"r2r3r8r;rrrrrr.s"
	rc@s&eZdZd	dd�Zdd�Zdd�ZdS)
rrcCstj|t|t|d�dS�N�r*)rr-�	SEMAPHORE�
SEM_VALUE_MAX�r&r(r*rrrr-}szSemaphore.__init__cCs
|j��Sr)r�
_get_valuer1rrr�	get_value�szSemaphore.get_valuecCs8z|j��}Wntk
r&d}YnXd|jj|fS)N�unknownz<%s(value=%s)>)rrI�	Exception�	__class__r?�r&r(rrr�__repr__�s

zSemaphore.__repr__N)r)r?r@rAr-rJrOrrrrr{s
c@seZdZddd�Zdd�ZdS)rrcCstj|t|||d�dSrD�rr-rFrHrrrr-�szBoundedSemaphore.__init__cCs>z|j��}Wntk
r&d}YnXd|jj||jjfS)NrKz<%s(value=%s, maxvalue=%s)>)rrIrLrMr?r)rNrrrrO�s
�zBoundedSemaphore.__repr__N)r�r?r@rAr-rOrrrrr�s
c@seZdZdd�Zdd�ZdS)rcCstj|tdd|d�dS�NrrErP�r&r*rrrr-�sz
Lock.__init__cCs�zf|j��r8t��j}t��jdkrd|dt��j7}n,|j��dkrLd}n|j��dkr`d}nd}Wnt	k
r~d}YnXd	|j
j|fS)
N�
MainThread�|r�Noner�SomeOtherThread�SomeOtherProcessrKz<%s(owner=%s)>)r�_is_miner
r<r#�	threading�current_threadrI�_countrLrMr?)r&r#rrrrO�s


z
Lock.__repr__NrQrrrrr�sc@seZdZdd�Zdd�ZdS)rcCstj|tdd|d�dSrR)rr-�RECURSIVE_MUTEXrSrrrr-�szRLock.__init__cCs�z||j��rBt��j}t��jdkr6|dt��j7}|j��}n8|j��dkrZd\}}n |j��dkrrd\}}nd\}}Wnt	k
r�d\}}YnXd	|j
j||fS)
NrTrUr)rVrr)rW�nonzero)rXr^)rKrK�<%s(%s, %s)>)rrYr
r<r#rZr[r\rIrLrMr?)r&r#�countrrrrO�s



zRLock.__repr__NrQrrrrr�sc@sleZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	ddd�Z
ddd�Zdd�Zddd�Z
dS)rNcCs>|p
|��|_|�d�|_|�d�|_|�d�|_|��dS�Nr)r�_lockr�_sleeping_count�_woken_count�_wait_semaphorer")r&�lockr*rrrr-�s
zCondition.__init__cCst�|�|j|j|j|jfSr)r	r6rbrcrdrer1rrrr8�s

�zCondition.__getstate__cCs |\|_|_|_|_|��dSr)rbrcrdrer"r9rrrr;�s
�
zCondition.__setstate__cCs
|j��Sr)rbr2r1rrrr2�szCondition.__enter__cGs|jj|�Sr)rbr3r4rrrr3�szCondition.__exit__cCs|jj|_|jj|_dSr)rbr/r0r1rrrr"�s
zCondition._make_methodscCsJz|jj��|jj��}Wntk
r4d}YnXd|jj|j|fS)NrKr_)rcrrIrdrLrMr?rb)r&Znum_waitersrrrrO�s

�
zCondition.__repr__c	Cs~|jj��std��|j��|jj��}t|�D]}|j��q2z|j
�	d|�W�S|j��t|�D]}|j�	�qhXdS)Nz,must acquire() condition before using wait()T)rbrrY�AssertionErrorrcr0r\rrdr/re)r&�timeoutr`r+rrr�wait�s�

zCondition.waitrcCs�|jj��std��|j�d�r(td��|j�d�rN|j�d�}|s(td��q(d}||krz|j�d�rz|j��|d7}qR|r�t	|�D]}|j��q�|j�d�r�q�dS)Nzlock is not ownedFz<notify: Should not have been able to acquire _wait_semaphorez>notify: Bug in sleeping_count.acquire- res should not be Falserr)
rbrrYrgrer/rdrcr0r)r&�n�resZsleepersr+rrr�notifys$��

zCondition.notifycCs|jtjd�dS)N)rj)rlr�maxsizer1rrr�
notify_all(szCondition.notify_allcCsd|�}|r|S|dk	r$t��|}nd}d}|s`|dk	rN|t��}|dkrNq`|�|�|�}q,|Sra)�time�	monotonicri)r&Z	predicaterh�resultZendtimeZwaittimerrr�wait_for+s
zCondition.wait_for)N)N)r)N)r?r@rAr-r8r;r2r3r"rOrirlrnrrrrrrr�s


c@s6eZdZdd�Zdd�Zdd�Zdd�Zdd
d�Zd	S)
rcCs |�|���|_|�d�|_dSra)rr�_condr�_flagrSrrrr-CszEvent.__init__c	CsD|j�4|j�d�r,|j��W5QR�dSW5QR�dSQRXdS�NFT)rsrtr/r0r1rrr�is_setGs

zEvent.is_setc	Cs6|j�&|j�d�|j��|j��W5QRXdS�NF)rsrtr/r0rnr1rrr�setNs
z	Event.setc	Cs"|j�|j�d�W5QRXdSrw)rsrtr/r1rrr�clearTszEvent.clearNc	Csh|j�X|j�d�r |j��n|j�|�|j�d�rP|j��W5QR�dSW5QR�dSQRXdSru)rsrtr/r0ri)r&rhrrrriXs
z
Event.wait)N)r?r@rAr-rvrxryrirrrrrAs
c@sZeZdZddd�Zdd�Zdd�Zedd	��Zejd
d	��Zedd��Z	e	jd
d��Z	dS)�BarrierNc	CsRddl}ddlm}||�d�d�}|��}|�|||||f�d|_d|_dS)Nrr)�
BufferWrapperr+r)�struct�heapr{Zcalcsizerr;�_stater\)	r&Zparties�actionrhr*r|r{�wrapperZcondrrrr-jszBarrier.__init__cCs.|\|_|_|_|_|_|j���d�|_dS)Nr+)�_parties�_action�_timeoutrs�_wrapperZcreate_memoryview�cast�_arrayr9rrrr;ss
�zBarrier.__setstate__cCs|j|j|j|j|jfSr)r�r�r�rsr�r1rrrr8xs�zBarrier.__getstate__cCs
|jdSra�r�r1rrrr~|szBarrier._statecCs||jd<dSrar�rNrrrr~�scCs
|jdS�Nrr�r1rrrr\�szBarrier._countcCs||jd<dSr�r�rNrrrr\�s)NN)
r?r@rAr-r;r8�propertyr~�setterr\rrrrrzhs
	


rz)�__all__rZrrBrro�r	r
rrr
�ImportError�listrr]rFrG�objectrrrrrrrzrrrr�<module>s8�	Mo'