diff options
author | Yury Selivanov <yury@magic.io> | 2018-09-14 16:57:11 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-14 16:57:11 -0700 |
commit | 805e27eff65d51f7aea2c00ccbb4f5d44f4499f2 (patch) | |
tree | 1a41e7b052f4d0845c29a6c9bcf594f0d0cffe63 /Doc/library/asyncio-future.rst | |
parent | afde1c1a05cc8a1e8adf6403c451f6708509a605 (diff) | |
download | cpython-git-805e27eff65d51f7aea2c00ccbb4f5d44f4499f2.tar.gz |
bpo-33649: Fix asyncio-dev (GH-9324)
Diffstat (limited to 'Doc/library/asyncio-future.rst')
-rw-r--r-- | Doc/library/asyncio-future.rst | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Doc/library/asyncio-future.rst b/Doc/library/asyncio-future.rst index ff04339d85..19bf8a6e05 100644 --- a/Doc/library/asyncio-future.rst +++ b/Doc/library/asyncio-future.rst @@ -121,6 +121,16 @@ Future Object or an exception set with :meth:`set_result` or :meth:`set_exception` calls. + .. method:: cancelled() + + Return ``True`` if the Future was *cancelled*. + + The method is usually used to check if a Future is not + *cancelled* before setting a result or an exception for it:: + + if not fut.cancelled(): + fut.set_result(42) + .. method:: add_done_callback(callback, *, context=None) Add a callback to be run when the Future is *done*. @@ -180,10 +190,6 @@ Future Object .. versionadded:: 3.7 - .. method:: cancelled() - - Return ``True`` if the Future was *cancelled*. - This example creates a Future object, creates and schedules an asynchronous Task to set result for the Future, and waits until |