Unverified Kaydet (Commit) a7a751dd authored tarafından Antoine Pitrou's avatar Antoine Pitrou Kaydeden (comit) GitHub

bpo-32306: Clarify c.f.Executor.map() documentation (#4947)

The built-in map() function collects function arguments lazily, but concurrent.futures.Executor.map() does so eagerly.
üst 6b91a597
...@@ -40,21 +40,29 @@ Executor Objects ...@@ -40,21 +40,29 @@ Executor Objects
.. method:: map(func, *iterables, timeout=None, chunksize=1) .. method:: map(func, *iterables, timeout=None, chunksize=1)
Equivalent to :func:`map(func, *iterables) <map>` except *func* is executed Similar to :func:`map(func, *iterables) <map>` except:
asynchronously and several calls to *func* may be made concurrently. The
returned iterator raises a :exc:`concurrent.futures.TimeoutError` if * the *iterables* are collected immediately rather than lazily;
:meth:`~iterator.__next__` is called and the result isn't available
* *func* is executed asynchronously and several calls to
*func* may be made concurrently.
The returned iterator raises a :exc:`concurrent.futures.TimeoutError`
if :meth:`~iterator.__next__` is called and the result isn't available
after *timeout* seconds from the original call to :meth:`Executor.map`. after *timeout* seconds from the original call to :meth:`Executor.map`.
*timeout* can be an int or a float. If *timeout* is not specified or *timeout* can be an int or a float. If *timeout* is not specified or
``None``, there is no limit to the wait time. If a call raises an ``None``, there is no limit to the wait time.
exception, then that exception will be raised when its value is
retrieved from the iterator. When using :class:`ProcessPoolExecutor`, this If a *func* call raises an exception, then that exception will be
method chops *iterables* into a number of chunks which it submits to the raised when its value is retrieved from the iterator.
pool as separate tasks. The (approximate) size of these chunks can be
specified by setting *chunksize* to a positive integer. For very long When using :class:`ProcessPoolExecutor`, this method chops *iterables*
iterables, using a large value for *chunksize* can significantly improve into a number of chunks which it submits to the pool as separate
performance compared to the default size of 1. With :class:`ThreadPoolExecutor`, tasks. The (approximate) size of these chunks can be specified by
*chunksize* has no effect. setting *chunksize* to a positive integer. For very long iterables,
using a large value for *chunksize* can significantly improve
performance compared to the default size of 1. With
:class:`ThreadPoolExecutor`, *chunksize* has no effect.
.. versionchanged:: 3.5 .. versionchanged:: 3.5
Added the *chunksize* argument. Added the *chunksize* argument.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment