ok

Mini Shell

Direktori : /opt/alt/python38/lib64/python3.8/asyncio/__pycache__/
Upload File :
Current File : //opt/alt/python38/lib64/python3.8/asyncio/__pycache__/locks.cpython-38.opt-2.pyc

U

.��c|C�@s�dZddlZddlZddlZddlmZddlmZddlmZddlmZGdd	�d	�Z	Gd
d�d�Z
Gdd
�d
e
�ZGdd�d�ZGdd�de
�Z
Gdd�de
�ZGdd�de�ZdS))�Lock�Event�	Condition�	Semaphore�BoundedSemaphore�N�)�events)�futures)�
exceptions)�
coroutinesc@s$eZdZdd�Zdd�Zdd�ZdS)�_ContextManagercCs
||_dS�N)�_lock)�self�lock�r�2/opt/alt/python38/lib64/python3.8/asyncio/locks.py�__init__"sz_ContextManager.__init__cCsdSr
r�rrrr�	__enter__%sz_ContextManager.__enter__cGsz|j��W5d|_XdSr
)r�release�r�argsrrr�__exit__*sz_ContextManager.__exit__N)�__name__�
__module__�__qualname__rrrrrrrrsrc@sReZdZdd�Zdd�Zejdd��Zej	e_	dd�Z
d	d
�Zdd�Zd
d�Z
dS)�_ContextManagerMixincCstd��dS)Nz9"yield from" should be used as context manager expression)�RuntimeErrorrrrrr2s�z_ContextManagerMixin.__enter__cGsdSr
rrrrrr6sz_ContextManagerMixin.__exit__ccs&tjdtdd�|��EdHt|�S)NzD'with (yield from lock)' is deprecated use 'async with lock' instead���
stacklevel)�warnings�warn�DeprecationWarning�acquirerrrrr�__iter__;s�z_ContextManagerMixin.__iter__c�s|��IdHt|�Sr
)r%rrrrrZ
__acquire_ctxUsz"_ContextManagerMixin.__acquire_ctxcCstjdtdd�|����S)Nz='with await lock' is deprecated use 'async with lock' insteadrr )r"r#r$�!_ContextManagerMixin__acquire_ctx�	__await__rrrrr(Ys
�z_ContextManagerMixin.__await__c�s|��IdHdSr
)r%rrrr�
__aenter__`sz_ContextManagerMixin.__aenter__c�s|��dSr
)r)r�exc_type�exc�tbrrr�	__aexit__fsz_ContextManagerMixin.__aexit__N)rrrrr�types�	coroutiner&rZ
_is_coroutiner'r(r)r-rrrrr1s
rcsJeZdZdd�dd�Z�fdd�Zdd�Zd	d
�Zdd�Zd
d�Z�Z	S)rN��loopcCs:d|_d|_|dkr t��|_n||_tjdtdd�dS�NF�[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.rr )�_waiters�_lockedr�get_event_loop�_loopr"r#r$�rr1rrrr�s�z
Lock.__init__csLt���}|jrdnd}|jr2|�dt|j���}d|dd��d|�d�S�	N�lockedZunlocked�
, waiters:�<r���� [�]>)�super�__repr__r5r4�len�r�resZextra��	__class__rrrA�s

z
Lock.__repr__cCs|jSr
)r5rrrrr:�szLock.lockedc	�s�|js.|jdks$tdd�|jD��r.d|_dS|jdkrBt��|_|j��}|j�|�z"z|IdHW5|j�|�XWn&t	j
k
r�|js�|���YnXd|_dS)Ncss|]}|��VqdSr
)�	cancelled)�.0�wrrr�	<genexpr>�szLock.acquire.<locals>.<genexpr>T)r5r4�all�collections�dequer7�
create_future�append�remover
�CancelledError�_wake_up_first�r�futrrrr%�s&�


zLock.acquirecCs"|jrd|_|��ntd��dS)NFzLock is not acquired.)r5rRrrrrrr�s
zLock.releasecCsJ|js
dSztt|j��}Wntk
r2YdSX|��sF|�d�dS�NT)r4�next�iter�
StopIteration�done�
set_resultrSrrrrR�szLock._wake_up_first)
rrrrrAr:r%rrR�
__classcell__rrrErrjs6 rcsJeZdZdd�dd�Z�fdd�Zdd�Zd	d
�Zdd�Zd
d�Z�Z	S)rNr0cCs>t��|_d|_|dkr$t��|_n||_tjdt	dd�dSr2)
rLrMr4�_valuerr6r7r"r#r$r8rrrrs
�zEvent.__init__csLt���}|jrdnd}|jr2|�dt|j���}d|dd��d|�d�S)	N�setZunsetr;r<rr=r>r?)r@rAr\r4rBrCrErrrAs

zEvent.__repr__cCs|jSr
�r\rrrr�is_setszEvent.is_setcCs.|js*d|_|jD]}|��s|�d�qdSrU)r\r4rYrZrSrrrr]s

z	Event.setcCs
d|_dS)NFr^rrrr�clear"szEvent.clearc	�sF|jr
dS|j��}|j�|�z|IdHW�dS|j�|�XdSrU)r\r7rNr4rOrPrSrrr�wait(s

z
Event.wait)
rrrrrAr_r]r`rar[rrrErr�s	rcsNeZdZddd�dd�Z�fdd�Zdd�Zd	d
�Zddd
�Zdd�Z�Z	S)rNr0cCs~|dkrt��|_n||_tjdtdd�|dkr>t|d�}n|j|jk	rRtd��||_|j	|_	|j
|_
|j|_t�
�|_dS)Nr3rr r0z"loop argument must agree with lock)rr6r7r"r#r$r�
ValueErrorrr:r%rrLrMr4)rrr1rrrrEs �zCondition.__init__csNt���}|��rdnd}|jr4|�dt|j���}d|dd��d|�d�Sr9)r@rAr:r4rBrCrErrrA[s

zCondition.__repr__c�s�|��std��|��z@|j��}|j�	|�z|IdHW�W�dS|j�
|�XW5d}z|��IdHWq�Wq^tjk
r�d}Yq^Xq^|r�tj�XdS)Nzcannot wait on un-acquired lockFT)r:rrr%r
rQr7rNr4rOrP)rrGrTrrrrabs$

zCondition.waitc�s$|�}|s |��IdH|�}q|Sr
)ra)rZ	predicate�resultrrr�wait_for�s
zCondition.wait_forrcCsJ|��std��d}|jD]*}||kr*qF|��s|d7}|�d�qdS)Nz!cannot notify on un-acquired lockrrF)r:rr4rYrZ)r�n�idxrTrrr�notify�s
zCondition.notifycCs|�t|j��dSr
)rgrBr4rrrr�
notify_all�szCondition.notify_all)N)r)
rrrrrArardrgrhr[rrrErr;s
%
rcsLeZdZddd�dd�Z�fdd�Zdd	�Zd
d�Zdd
�Zdd�Z�Z	S)rrNr0cCsN|dkrtd��||_t��|_|dkr4t��|_n||_tj	dt
dd�dS)Nrz$Semaphore initial value must be >= 0r3rr )rbr\rLrMr4rr6r7r"r#r$�r�valuer1rrrr�s
�zSemaphore.__init__csVt���}|��rdn
d|j��}|jr<|�dt|j���}d|dd��d|�d�S)	Nr:zunlocked, value:r;r<rr=r>r?)r@rAr:r\r4rBrCrErrrA�s

zSemaphore.__repr__cCs,|jr(|j��}|��s|�d�dSqdSr
)r4�popleftrYrZ)rZwaiterrrr�
_wake_up_next�s


zSemaphore._wake_up_nextcCs
|jdkS)Nrr^rrrrr:�szSemaphore.lockedc�st|jdkrb|j��}|j�|�z|IdHWq|��|jdkrX|��sX|���YqXq|jd8_dS)NrrT)r\r7rNr4rOZcancelrGrlrSrrrr%�s	


zSemaphore.acquirecCs|jd7_|��dS)Nr)r\rlrrrrr�szSemaphore.release)r)
rrrrrArlr:r%rr[rrrErr�s
rcs0eZdZddd��fdd�Z�fdd�Z�ZS)	rrNr0cs.|rtjdtdd�||_t�j||d�dS)Nr3rr r0)r"r#r$�_bound_valuer@rrirErrr
s�zBoundedSemaphore.__init__cs"|j|jkrtd��t���dS)Nz(BoundedSemaphore released too many times)r\rmrbr@rrrErrrszBoundedSemaphore.release)r)rrrrrr[rrrErrs	r)�__all__rLr.r"�rr	r
rrrrrrrrrrrr�<module>s"9DzN

Zerion Mini Shell 1.0