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

miss-islington webhook-mailer at python.org
Tue Nov 16 06:47:07 EST 2021


https://github.com/python/cpython/commit/fd206b680705de3e0408fd29c7943317563e61e1
commit: fd206b680705de3e0408fd29c7943317563e61e1
branch: 3.9
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2021-11-16T03:47:02-08:00
summary:

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



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


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

Automerge-Triggered-By: GH:asvetlov

files:
M Doc/library/asyncio-future.rst
M Doc/library/asyncio-task.rst

diff --git a/Doc/library/asyncio-future.rst b/Doc/library/asyncio-future.rst
index 939d4c1a84523..63c369263fd99 100644
--- a/Doc/library/asyncio-future.rst
+++ b/Doc/library/asyncio-future.rst
@@ -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.
 
diff --git a/Doc/library/asyncio-task.rst b/Doc/library/asyncio-task.rst
index ca6e525e93597..e8bee20bc76bc 100644
--- a/Doc/library/asyncio-task.rst
+++ b/Doc/library/asyncio-task.rst
@@ -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



More information about the Python-checkins mailing list