Skip to content
Merged
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
Add docs and NEWS entry.
  • Loading branch information
cjerdonek committed May 14, 2020
commit 403baa28f49019a7c948a68f6d3882580f40dee5
8 changes: 7 additions & 1 deletion Doc/library/asyncio-future.rst
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,17 @@ Future Object
Returns the number of callbacks removed, which is typically 1,
unless a callback was added more than once.

.. method:: cancel()
.. method:: cancel(msg=None)

Cancel the Future and schedule callbacks.

If the Future is already *done* or *cancelled*, return ``False``.
Otherwise, change the Future's state to *cancelled*,
schedule the callbacks, and return ``True``.

.. versionchanged:: 3.9
Added the ``msg`` parameter.

.. method:: exception()

Return the exception that was set on this Future.
Expand Down Expand Up @@ -255,3 +258,6 @@ the Future has a result::
- asyncio Future is not compatible with the
:func:`concurrent.futures.wait` and
:func:`concurrent.futures.as_completed` functions.

- :meth:`asyncio.Future.cancel` accepts an optional ``msg`` argument,
but :func:`concurrent.futures.cancel` does not.
5 changes: 4 additions & 1 deletion Doc/library/asyncio-task.rst
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ Task Object
.. deprecated-removed:: 3.8 3.10
The *loop* parameter.

.. method:: cancel()
.. method:: cancel(msg=None)

Request the Task to be cancelled.

Expand All @@ -738,6 +738,9 @@ Task Object
suppressing cancellation completely is not common and is actively
discouraged.

.. versionchanged:: 3.9
Added the ``msg`` parameter.

.. _asyncio_example_task_cancel:

The following example illustrates how coroutines can intercept
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add a ``msg`` argument to :meth:`Future.cancel` and :meth:`Task.cancel`.