]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.9] Save a reference for ensure_future and create_task (GH-29163) (GH-29573)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 16 Nov 2021 11:47:02 +0000 (03:47 -0800)
committerGitHub <noreply@github.com>
Tue, 16 Nov 2021 11:47:02 +0000 (03:47 -0800)
Co-authored-by: Joannah Nanjekye <jnanjekye@python.org>
(cherry picked from commit c750adbe6990ee8239b27d5f4591283a06bfe862)

Co-authored-by: Joannah Nanjekye <33177550+nanjekyejoannah@users.noreply.github.com>
Automerge-Triggered-By: GH:asvetlov
Doc/library/asyncio-future.rst
Doc/library/asyncio-task.rst

index 939d4c1a84523a057cc9e360c7782dda459dc761..63c369263fd99bf849c19a5feefa9ea829935448 100644 (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.
 
index ca6e525e93597753ea691b29e69b2c6781f8908c..e8bee20bc76bc77eb113a0f80f34c695d6f741f6 100644 (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