From d5bd517c1305005a7a3148248f9c4d36247e8310 Mon Sep 17 00:00:00 2001 From: Ollanta Cuba Gyllensten Date: Fri, 29 Nov 2024 17:20:40 +0100 Subject: [PATCH 1/2] Link to correct class methods in asyncio primitives docs (#127270) --- Doc/library/asyncio-sync.rst | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Doc/library/asyncio-sync.rst b/Doc/library/asyncio-sync.rst index 05bdf5488af143..9447fa5df25140 100644 --- a/Doc/library/asyncio-sync.rst +++ b/Doc/library/asyncio-sync.rst @@ -257,13 +257,19 @@ 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:`~Condition.wait` again. For this reason, you may + prefer to use :meth:`~Condition.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 - return value. + interpreted as a boolean value. The method will repeatedly + :meth:`~Condition.wait` until the predicate evaluates to *true*. + The final value is the return value. Semaphore @@ -428,7 +434,7 @@ Barrier .. coroutinemethod:: abort() Put the barrier into a broken state. This causes any active or future - calls to :meth:`wait` to fail with the :class:`BrokenBarrierError`. + calls to :meth:`~Barrier.wait` to fail with the :class:`BrokenBarrierError`. Use this for example if one of the tasks needs to abort, to avoid infinite waiting tasks. From 5380f04e3cb676e31eb0c021d767669402749245 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Sat, 30 Nov 2024 10:54:15 +0100 Subject: [PATCH 2/2] Update asyncio-sync.rst This removes the irrelevant note for 3.12. --- Doc/library/asyncio-sync.rst | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Doc/library/asyncio-sync.rst b/Doc/library/asyncio-sync.rst index 9447fa5df25140..4caa8b9b47564a 100644 --- a/Doc/library/asyncio-sync.rst +++ b/Doc/library/asyncio-sync.rst @@ -257,11 +257,6 @@ 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:`~Condition.wait` again. For this reason, you may - prefer to use :meth:`~Condition.wait_for` instead. - .. coroutinemethod:: wait_for(predicate) Wait until a predicate becomes *true*.