AlkantarClanX12

Your IP : 18.226.248.88


Current Path : /opt/alt/python35/lib64/python3.5/asyncio/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/asyncio/__pycache__/locks.cpython-35.opt-2.pyc



���]�:�@s�dddddgZddlZddlmZdd	lmZdd
lmZddlmZGdd
�d
�ZGdd�d�Z	Gdd�de	�Z
Gdd�d�ZGdd�de	�ZGdd�de	�Z
Gdd�de
�ZdS)�Lock�Event�	Condition�	Semaphore�BoundedSemaphore�N�)�compat)�events)�futures)�	coroutinec@s4eZdZdd�Zdd�Zdd�ZdS)�_ContextManagercCs
||_dS)N)�_lock)�self�lock�r�*/opt/alt/python35/lib64/python3.5/locks.py�__init__sz_ContextManager.__init__cCsdS)Nr)rrrr�	__enter__sz_ContextManager.__enter__cGs"z|jj�Wdd|_XdS)N)r
�release)r�argsrrr�__exit__$sz_ContextManager.__exit__N)�__name__�
__module__�__qualname__rrrrrrrr
src@sseZdZdd�Zdd�Zedd��Zejrodd�Z	ed	d
��Z
edd��Zd
S)�_ContextManagerMixincCstd��dS)Nz9"yield from" should be used as context manager expression)�RuntimeError)rrrrr,sz_ContextManagerMixin.__enter__cGsdS)Nr)rrrrrr0sz_ContextManagerMixin.__exit__ccs|j�EdHt|�S)N)�acquirer)rrrr�__iter__5sz_ContextManagerMixin.__iter__ccs|j�EdHt|�S)N)rr)rrrr�	__await__Hsz_ContextManagerMixin.__await__ccs|j�EdHdS)N)r)rrrr�
__aenter__Msz_ContextManagerMixin.__aenter__cCs|j�dS)N)r)r�exc_type�exc�tbrrr�	__aexit__Tsz_ContextManagerMixin.__aexit__N)rrrrrrrrZPY35rrr#rrrrr+s	rcsjeZdZdddd�Z�fdd�Zdd�Zed	d
��Zdd�Zd
d�Z	�S)r�loopNcCsCtj�|_d|_|dk	r0||_ntj�|_dS)NF)�collections�deque�_waiters�_locked�_loopr	�get_event_loop)rr$rrrr�s
	z
Lock.__init__csbt�j�}|jrdnd}|jrHdj|t|j��}dj|dd�|�S)N�locked�unlockedz
{},waiters:{}z	<{} [{}]>r���)�super�__repr__r(r'�format�len)r�res�extra)�	__class__rrr/�s
	z
Lock.__repr__cCs|jS)N)r()rrrrr+�szLock.lockedccs�|jr3tdd�|jD��r3d|_dS|jj�}|jj|�zLy|EdHd|_dSWn+tjk
r�|js�|j��YnXWd|jj	|�XdS)Ncss|]}|j�VqdS)N)�	cancelled)�.0�wrrr�	<genexpr>�szLock.acquire.<locals>.<genexpr>T)
r(�allr'r)�
create_future�appendr
�CancelledError�_wake_up_first�remove)r�futrrrr�s&				
zLock.acquirecCs/|jrd|_|j�ntd��dS)NFzLock is not acquired.)r(r=r)rrrrr�s		
zLock.releasecCs2x+|jD] }|j�s
|jd�Pq
WdS)NT)r'�done�
set_result)rr?rrrr=�s
zLock._wake_up_first)
rrrrr/r+rrrr=rr)r4rrYs6csjeZdZdddd�Z�fdd�Zdd�Zd	d
�Zdd�Zed
d��Z	�S)rr$NcCsCtj�|_d|_|dk	r0||_ntj�|_dS)NF)r%r&r'�_valuer)r	r*)rr$rrrr�s
	zEvent.__init__csbt�j�}|jrdnd}|jrHdj|t|j��}dj|dd�|�S)N�setZunsetz
{},waiters:{}z	<{} [{}]>rr-)r.r/rBr'r0r1)rr2r3)r4rrr/�s
	zEvent.__repr__cCs|jS)N)rB)rrrr�is_set�szEvent.is_setcCsC|js?d|_x*|jD]}|j�s|jd�qWdS)NT)rBr'r@rA)rr?rrrrC�s
		z	Event.setcCs
d|_dS)NF)rB)rrrr�clear�szEvent.clearccsU|jr
dS|jj�}|jj|�z|EdHdSWd|jj|�XdS)NT)rBr)r:r'r;r>)rr?rrr�waits		z
Event.wait)
rrrrr/rDrCrErrFrr)r4rr�s	csveZdZddddd�Z�fdd�Zedd��Zed	d
��Zddd
�Zdd�Z	�S)rNr$cCs�|dk	r||_ntj�|_|dkrHtd|j�}n|j|jk	rftd��||_|j|_|j|_|j|_t	j
�|_dS)Nr$z"loop argument must agree with lock)r)r	r*r�
ValueErrorr
r+rrr%r&r')rrr$rrrrs	zCondition.__init__cset�j�}|j�r!dnd}|jrKdj|t|j��}dj|dd�|�S)Nr+r,z
{},waiters:{}z	<{} [{}]>rr-)r.r/r+r'r0r1)rr2r3)r4rrr/2s
	zCondition.__repr__ccs�|j�std��|j�zH|jj�}|jj|�z|EdHdSWd|jj|�XWdx0y|j�EdHPWqpt	j
k
r�YqpXqpWXdS)Nzcannot wait on un-acquired lockT)r+rrr)r:r'r;r>rr
r<)rr?rrrrF9s 
	zCondition.waitccs2|�}x"|s-|j�EdH|�}qW|S)N)rF)r�	predicate�resultrrr�wait_for[s
		
zCondition.wait_forrcCsf|j�std��d}xA|jD]6}||kr;P|j�s(|d7}|jd�q(WdS)Nz!cannot notify on un-acquired lockrrF)r+rr'r@rA)r�n�idxr?rrr�notifyis
zCondition.notifycCs|jt|j��dS)N)rMr1r')rrrr�
notify_all�szCondition.notify_all)
rrrrr/rrFrJrMrNrr)r4rrs
"csmeZdZddddd�Z�fdd�Zdd	�Zd
d�Zedd
��Zdd�Z	�S)rrr$NcCs[|dkrtd��||_tj�|_|dk	rH||_ntj�|_dS)Nrz$Semaphore initial value must be >= 0)rGrBr%r&r'r)r	r*)r�valuer$rrrr�s	zSemaphore.__init__csqt�j�}|j�r!dndj|j�}|jrWdj|t|j��}dj|dd�|�S)Nr+zunlocked,value:{}z
{},waiters:{}z	<{} [{}]>rr-)r.r/r+r0rBr'r1)rr2r3)r4rrr/�s	zSemaphore.__repr__cCs@x9|jr;|jj�}|j�s|jd�dSqWdS)N)r'�popleftr@rA)r�waiterrrr�
_wake_up_next�s

zSemaphore._wake_up_nextcCs
|jdkS)Nr)rB)rrrrr+�szSemaphore.lockedc	cs�x}|jdkr|jj�}|jj|�y
|EdHWq|j�|jdkrt|j�rt|j��YqXqW|jd8_dS)NrrT)rBr)r:r'r;�cancelr5rR)rr?rrrr�s



zSemaphore.acquirecCs|jd7_|j�dS)Nr)rBrR)rrrrr�szSemaphore.release)
rrrrr/rRr+rrrrr)r4rr�s
cs=eZdZddd�fdd�Z�fdd�Z�S)rrr$Ncs#||_t�j|d|�dS)Nr$)�_bound_valuer.r)rrOr$)r4rrr�s	zBoundedSemaphore.__init__cs/|j|jkrtd��t�j�dS)Nz(BoundedSemaphore released too many times)rBrTrGr.r)r)r4rrr�szBoundedSemaphore.release)rrrrrrr)r4rr�s)�__all__r%�rr	r
Z
coroutinesrrrrrrrrrrrr�<module>s.zBuM