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

Skip to content

Commit bf9d34c

Browse files
committed
Issue 12767: document the argument of threading.Condition.notify
2 parents 31b92a5 + d44af82 commit bf9d34c

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

Doc/library/threading.rst

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -656,20 +656,21 @@ the call as often as necessary.
656656

657657
.. versionadded:: 3.2
658658

659-
.. method:: notify()
659+
.. method:: notify(n=1)
660660

661-
Wake up a thread waiting on this condition, if any. If the calling thread
662-
has not acquired the lock when this method is called, a
661+
By default, wake up one thread waiting on this condition, if any. If the
662+
calling thread has not acquired the lock when this method is called, a
663663
:exc:`RuntimeError` is raised.
664664

665-
This method wakes up one of the threads waiting for the condition
666-
variable, if any are waiting; it is a no-op if no threads are waiting.
665+
This method wakes up at most *n* of the threads waiting for the condition
666+
variable; it is a no-op if no threads are waiting.
667667

668-
The current implementation wakes up exactly one thread, if any are
669-
waiting. However, it's not safe to rely on this behavior. A future,
670-
optimized implementation may occasionally wake up more than one thread.
668+
The current implementation wakes up exactly *n* threads, if at least *n*
669+
threads are waiting. However, it's not safe to rely on this behavior.
670+
A future, optimized implementation may occasionally wake up more than
671+
*n* threads.
671672

672-
Note: the awakened thread does not actually return from its :meth:`wait`
673+
Note: an awakened thread does not actually return from its :meth:`wait`
673674
call until it can reacquire the lock. Since :meth:`notify` does not
674675
release the lock, its caller should.
675676

0 commit comments

Comments
 (0)