Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 39930c9

Browse files
committed
Close #20889: asyncio doc: Document acquire(), locked() and release() method of
Condition
1 parent d079d3a commit 39930c9

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

Doc/library/asyncio-sync.rst

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Lock
6464

6565
.. method:: locked()
6666

67-
Return ``True`` if lock is acquired.
67+
Return ``True`` if the lock is acquired.
6868

6969
.. method:: acquire()
7070

@@ -141,6 +141,15 @@ Condition
141141

142142
A new :class:`Lock` object is created and used as the underlying lock.
143143

144+
.. method:: acquire()
145+
146+
Acquire the underlying lock.
147+
148+
This method blocks until the lock is unlocked, then sets it to locked and
149+
returns ``True``.
150+
151+
This method is a :ref:`coroutine <coroutine>`.
152+
144153
.. method:: notify(n=1)
145154

146155
By default, wake up one coroutine waiting on this condition, if any.
@@ -156,13 +165,29 @@ Condition
156165
call until it can reacquire the lock. Since :meth:`notify` does not
157166
release the lock, its caller should.
158167

168+
.. method:: locked()
169+
170+
Return ``True`` if the underlying lock is acquired.
171+
159172
.. method:: notify_all()
160173

161174
Wake up all threads waiting on this condition. This method acts like
162175
:meth:`notify`, but wakes up all waiting threads instead of one. If the
163176
calling thread has not acquired the lock when this method is called, a
164177
:exc:`RuntimeError` is raised.
165178

179+
.. method:: release()
180+
181+
Release the underlying lock.
182+
183+
When the lock is locked, reset it to unlocked, and return. If any other
184+
coroutines are blocked waiting for the lock to become unlocked, allow
185+
exactly one of them to proceed.
186+
187+
When invoked on an unlocked lock, a :exc:`RuntimeError` is raised.
188+
189+
There is no return value.
190+
166191
.. method:: wait()
167192

168193
Wait until notified.

0 commit comments

Comments
 (0)