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

Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Clarify use of the lock. Add message to the ValueError.
  • Loading branch information
rhettinger committed Apr 23, 2026
commit adcb718b3341e7dbaad9d1b620ea6f85b13d6320
7 changes: 3 additions & 4 deletions Doc/library/threading.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1464,10 +1464,9 @@ of the derived iterators.
:meth:`~iterator.__next__` using a lock.

This makes it possible to share a single iterator, including a generator
iterator, between multiple threads. Calls are handled one at a time in
arrival order determined by lock acquisition. No values are duplicated or
skipped by the wrapper itself. Each item produced by the underlying iterator
is given to exactly one caller.
iterator, between multiple threads. A lock assures that calls are handled
one at a time. No values are duplicated or skipped by the wrapper itself.
Each item from the underlying iterator is given to exactly one caller.

This wrapper does not copy or buffer values. Threads that call
:func:`next` while another thread is already advancing the iterator will
Expand Down
2 changes: 1 addition & 1 deletion Lib/threading.py
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ def concurrent_tee(iterable, n=2):
"""

if n < 0:
raise ValueError
raise ValueError("n must be positive integer")
if n == 0:
return ()
iterator = _concurrent_tee(iterable)
Expand Down