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

willingc webhook-mailer at python.org
Mon Nov 15 17:30:36 EST 2021


https://github.com/python/cpython/commit/c750adbe6990ee8239b27d5f4591283a06bfe862
commit: c750adbe6990ee8239b27d5f4591283a06bfe862
branch: main
author: Joannah Nanjekye <33177550+nanjekyejoannah at users.noreply.github.com>
committer: willingc <carolcode at willingconsulting.com>
date: 2021-11-15T14:30:28-08:00
summary:

Save a reference for ensure_future and create_task (GH-29163)

Co-authored-by: Joannah Nanjekye <jnanjekye at python.org>

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 ef496a23f5cd4..3496387c178af 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 07354e028b12a..36e13f9295652 100644
--- a/Doc/library/asyncio-task.rst
+++ b/Doc/library/asyncio-task.rst
@@ -271,6 +271,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