Skip to content

Commit

Permalink
[3.9] Save a reference for ensure_future and create_task (GH-29163) (G…
Browse files Browse the repository at this point in the history
…H-29573)

Co-authored-by: Joannah Nanjekye <jnanjekye@python.org>
(cherry picked from commit c750adb)


Co-authored-by: Joannah Nanjekye <33177550+nanjekyejoannah@users.noreply.github.com>

Automerge-Triggered-By: GH:asvetlov
  • Loading branch information
miss-islington authored Nov 16, 2021
1 parent a40d066 commit fd206b6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Doc/library/asyncio-future.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ Future Functions
See also the :func:`create_task` function which is the
preferred way for creating new Tasks.

Save a reference to the result of this function, to avoid
a task disappearing mid execution.

.. versionchanged:: 3.5.1
The function accepts any :term:`awaitable` object.

Expand Down
5 changes: 5 additions & 0 deletions Doc/library/asyncio-task.rst
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,11 @@ Creating Tasks
task = asyncio.ensure_future(coro())
...

.. important::

Save a reference to the result of this function, to avoid
a task disappearing mid execution.

.. versionadded:: 3.7

.. versionchanged:: 3.8
Expand Down

0 comments on commit fd206b6

Please sign in to comment.