mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-112202: Ensure that condition.notify() succeeds even when racing with Task.cancel() (#112201)
Also did a general cleanup of asyncio locks.py comments and docstrings.
This commit is contained in:
parent
96bce033c4
commit
6b53d5fe04
4 changed files with 165 additions and 52 deletions
|
@ -216,8 +216,8 @@ Condition
|
|||
|
||||
.. method:: notify(n=1)
|
||||
|
||||
Wake up at most *n* tasks (1 by default) waiting on this
|
||||
condition. The method is no-op if no tasks are waiting.
|
||||
Wake up *n* tasks (1 by default) waiting on this
|
||||
condition. If fewer than *n* tasks are waiting they are all awakened.
|
||||
|
||||
The lock must be acquired before this method is called and
|
||||
released shortly after. If called with an *unlocked* lock
|
||||
|
@ -257,12 +257,18 @@ Condition
|
|||
Once awakened, the Condition re-acquires its lock and this method
|
||||
returns ``True``.
|
||||
|
||||
Note that a task *may* return from this call spuriously,
|
||||
which is why the caller should always re-check the state
|
||||
and be prepared to :meth:`wait` again. For this reason, you may
|
||||
prefer to use :meth:`wait_for` instead.
|
||||
|
||||
.. coroutinemethod:: wait_for(predicate)
|
||||
|
||||
Wait until a predicate becomes *true*.
|
||||
|
||||
The predicate must be a callable which result will be
|
||||
interpreted as a boolean value. The final value is the
|
||||
interpreted as a boolean value. The method will repeatedly
|
||||
:meth:`wait` until the predicate evaluates to *true*. The final value is the
|
||||
return value.
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue