[3.9] Save a reference for ensure_future and create_task (GH-29163) (GH-29573)

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


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

Automerge-Triggered-By: GH:asvetlov
This commit is contained in:
Miss Islington (bot) 2021-11-16 03:47:02 -08:00 committed by GitHub
parent a40d066e8e
commit fd206b6807
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View file

@ -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.

View file

@ -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