Skip to content

Commit

Permalink
doc: specify that it is the size of a buffer of tasks and not results
Browse files Browse the repository at this point in the history
  • Loading branch information
ebonnal committed Jan 12, 2025
1 parent 0892b2b commit 579ba31
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 17 deletions.
11 changes: 6 additions & 5 deletions Doc/library/concurrent.futures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ Executor Objects

Similar to :func:`map(fn, *iterables) <map>` except:

* the *iterables* are collected immediately rather than lazily, unless a
*buffersize* is specified: If the buffer is full, then the iteration
over *iterables* is paused until a result is yielded from the buffer.
* The *iterables* are collected immediately rather than lazily, unless a
*buffersize* is specified to limit the number of submitted tasks whose
results have not yet been yielded. If the buffer is full, iteration over
the *iterables* pauses until a result is yielded from the buffer.

* *fn* is executed asynchronously and several calls to
*fn* may be made concurrently.
Expand All @@ -70,10 +71,10 @@ Executor Objects
*chunksize* has no effect.

.. versionchanged:: 3.5
Added the *chunksize* argument.
Added the *chunksize* parameter.

.. versionchanged:: next
Added the *buffersize* argument.
Added the *buffersize* parameter.

.. method:: shutdown(wait=True, *, cancel_futures=False)

Expand Down
6 changes: 4 additions & 2 deletions Doc/whatsnew/3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,10 @@ concurrent.futures
(Contributed by Gregory P. Smith in :gh:`84559`.)

* Add the optional ``buffersize`` parameter to
:meth:`concurrent.futures.Executor.map` to specify the number
of results that can be buffered before being yielded.
:meth:`concurrent.futures.Executor.map` to limit the number of submitted
tasks whose results have not yet been yielded. If the buffer is full,
iteration over the *iterables* pauses until a result is yielded from the
buffer.
(Contributed by Enzo Bonnal and Josh Rosenberg in :gh:`74028`.)

ctypes
Expand Down
9 changes: 5 additions & 4 deletions Lib/concurrent/futures/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,10 +586,11 @@ def map(self, fn, *iterables, timeout=None, chunksize=1, buffersize=None):
before being passed to a child process. This argument is only
used by ProcessPoolExecutor; it is ignored by
ThreadPoolExecutor.
buffersize: The number of results that can be buffered before being
yielded. When the buffer is full, iteration over the input
iterables is paused until a result is yielded from the buffer.
If None, buffering is unlimited.
buffersize: The number of submitted tasks whose results have not
yet been yielded. If the buffer is full, iteration over the
iterables pauses until a result is yielded from the buffer.
If None, all input elements are eagerly collected, and a task is
submitted for each.
Returns:
An iterator equivalent to: map(func, *iterables) but the calls may
Expand Down
9 changes: 5 additions & 4 deletions Lib/concurrent/futures/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,10 +816,11 @@ def map(self, fn, *iterables, timeout=None, chunksize=1, buffersize=None):
chunksize: If greater than one, the iterables will be chopped into
chunks of size chunksize and submitted to the process pool.
If set to one, the items in the list will be sent one at a time.
buffersize: The number of result chunks that can be buffered before
being yielded. When the buffer is full, iteration over the
input iterables is paused until a result chunk is yielded from
the buffer. If None, buffering is unlimited.
buffersize: The number of submitted tasks whose results have not
yet been yielded. If the buffer is full, iteration over the
iterables pauses until a result is yielded from the buffer.
If None, all input elements are eagerly collected, and a task is
submitted for each.
Returns:
An iterator equivalent to: map(func, *iterables) but the calls may
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
Add the optional ``buffersize`` parameter to :meth:`concurrent.futures.Executor.map`
to specify the number of results that can be buffered before being yielded.
Add the optional ``buffersize`` parameter to
:meth:`concurrent.futures.Executor.map` to limit the number of submitted tasks
whose results have not yet been yielded. If the buffer is full, iteration over
the *iterables* pauses until a result is yielded from the buffer.

0 comments on commit 579ba31

Please sign in to comment.