Your IP : 18.226.34.148
�
�Q�f2J � �` � d Z dZddlZddlZddlmZ ddlmZ G d� d� Z G d � d
eej � Z G d� dej � Z
G d
� deej � Z G d� deej � Z G d� de� Z
G d� dej � Z G d� dej � Zy)zSynchronization primitives.)�Lock�Event� Condition� Semaphore�BoundedSemaphore�Barrier� N� )�
exceptions)�mixinsc � � e Zd Zd� Zd� Zy)�_ContextManagerMixinc � �@ K � | j � � d { ��� y 7 ��w�N)�acquire��selfs �4/opt/alt/python312/lib64/python3.12/asyncio/locks.py�
__aenter__z_ContextManagerMixin.__aenter__
s � �� ��l�l�n��� � �s ���c � �, K � | j � y �wr )�release)r �exc_type�exc�tbs r � __aexit__z_ContextManagerMixin.__aexit__ s � �� �����s �N)�__name__�
__module__�__qualname__r r � � r r
r
s � ��r r
c �@ � � e Zd ZdZd� Z� fd�Zd� Zd� Zd� Zd� Z � xZ
S )r a� Primitive lock objects.
A primitive lock is a synchronization primitive that is not owned
by a particular coroutine when locked. A primitive lock is in one
of two states, 'locked' or 'unlocked'.
It is created in the unlocked state. It has two basic methods,
acquire() and release(). When the state is unlocked, acquire()
changes the state to locked and returns immediately. When the
state is locked, acquire() blocks until a call to release() in
another coroutine changes it to unlocked, then the acquire() call
resets it to locked and returns. The release() method should only
be called in the locked state; it changes the state to unlocked
and returns immediately. If an attempt is made to release an
unlocked lock, a RuntimeError will be raised.
When more than one coroutine is blocked in acquire() waiting for
the state to turn to unlocked, only one coroutine proceeds when a
release() call resets the state to unlocked; first coroutine which
is blocked in acquire() is being processed.
acquire() is a coroutine and should be called with 'await'.
Locks also support the asynchronous context management protocol.
'async with lock' statement should be used.
Usage:
lock = Lock()
...
await lock.acquire()
try:
...
finally:
lock.release()
Context manager usage:
lock = Lock()
...
async with lock:
...
Lock objects can be tested for locking state:
if not lock.locked():
await lock.acquire()
else:
# lock is acquired
...
c � � d | _ d| _ y �NF)�_waiters�_lockedr s r �__init__z
Lock.__init__M s � ���
���r c � �� t �| � � }| j rdnd}| j r|� dt | j � � �}d|dd � d|� d�S � N�locked�unlocked�
, waiters:�<r ���� [�]>)�super�__repr__r$ r# �len�r �res�extra� __class__s �r r0 z
Lock.__repr__Q sY �� ��g�� �� �L�L��j���=�=��g�Z��D�M�M�(:�';�<�E��3�q��9�+�R��w�b�)�)r c � � | j S )z Return True if lock is acquired.)r$ r s r r( zLock.lockedX s � ��|�|�r c � �J K � | j s0| j �t d� | j D � � rd| _ y| j �t j � | _ | j � j
� }| j j |� |� d{ ��� | j j |� d| _ y7 �(# | j j |� w xY w# t j $ r | j s| j � � w xY w�w)z�Acquire a lock.
This method blocks until the lock is unlocked, then sets it to
locked and returns True.
Nc 3 �<