mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Update concurrent.futures.rst (GH-14061)
This PR adds missing details in the [`concurrent.futures`](https://docs.python.org/3/library/concurrent.futures.html) documentation:
* the mention that `Future.cancel` also returns `False` if the call finished running;
* the mention of the states for `Future` that did not complete: pending or running.
(cherry picked from commit 431478d5d7
)
Co-authored-by: Géry Ogam <gery.ogam@gmail.com>
This commit is contained in:
parent
8b66dbb212
commit
047fa1ddae
1 changed files with 8 additions and 6 deletions
|
@ -306,9 +306,10 @@ The :class:`Future` class encapsulates the asynchronous execution of a callable.
|
||||||
|
|
||||||
.. method:: cancel()
|
.. method:: cancel()
|
||||||
|
|
||||||
Attempt to cancel the call. If the call is currently being executed and
|
Attempt to cancel the call. If the call is currently being executed or
|
||||||
cannot be cancelled then the method will return ``False``, otherwise the
|
finished running and cannot be cancelled then the method will return
|
||||||
call will be cancelled and the method will return ``True``.
|
``False``, otherwise the call will be cancelled and the method will
|
||||||
|
return ``True``.
|
||||||
|
|
||||||
.. method:: cancelled()
|
.. method:: cancelled()
|
||||||
|
|
||||||
|
@ -423,8 +424,9 @@ Module Functions
|
||||||
Wait for the :class:`Future` instances (possibly created by different
|
Wait for the :class:`Future` instances (possibly created by different
|
||||||
:class:`Executor` instances) given by *fs* to complete. Returns a named
|
:class:`Executor` instances) given by *fs* to complete. Returns a named
|
||||||
2-tuple of sets. The first set, named ``done``, contains the futures that
|
2-tuple of sets. The first set, named ``done``, contains the futures that
|
||||||
completed (finished or were cancelled) before the wait completed. The second
|
completed (finished or cancelled futures) before the wait completed. The
|
||||||
set, named ``not_done``, contains uncompleted futures.
|
second set, named ``not_done``, contains the futures that did not complete
|
||||||
|
(pending or running futures).
|
||||||
|
|
||||||
*timeout* can be used to control the maximum number of seconds to wait before
|
*timeout* can be used to control the maximum number of seconds to wait before
|
||||||
returning. *timeout* can be an int or float. If *timeout* is not specified
|
returning. *timeout* can be an int or float. If *timeout* is not specified
|
||||||
|
@ -455,7 +457,7 @@ Module Functions
|
||||||
|
|
||||||
Returns an iterator over the :class:`Future` instances (possibly created by
|
Returns an iterator over the :class:`Future` instances (possibly created by
|
||||||
different :class:`Executor` instances) given by *fs* that yields futures as
|
different :class:`Executor` instances) given by *fs* that yields futures as
|
||||||
they complete (finished or were cancelled). Any futures given by *fs* that
|
they complete (finished or cancelled futures). Any futures given by *fs* that
|
||||||
are duplicated will be returned once. Any futures that completed before
|
are duplicated will be returned once. Any futures that completed before
|
||||||
:func:`as_completed` is called will be yielded first. The returned iterator
|
:func:`as_completed` is called will be yielded first. The returned iterator
|
||||||
raises a :exc:`concurrent.futures.TimeoutError` if :meth:`~iterator.__next__`
|
raises a :exc:`concurrent.futures.TimeoutError` if :meth:`~iterator.__next__`
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue