]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Save a reference for ensure_future and create_task (GH-29163)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 16 Nov 2021 11:51:19 +0000 (03:51 -0800)
committerGitHub <noreply@github.com>
Tue, 16 Nov 2021 11:51:19 +0000 (03:51 -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>
Doc/library/asyncio-future.rst
Doc/library/asyncio-task.rst

index ef496a23f5cd4c5b040b55a2812bd1b4fd2ebb10..3496387c178af75fa115603a3ed3c0b0b29bc765 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 fb86892547b5fc0e4db5ed5c9c175da3002c9b6b..f18b0e347b631494dc9607d49e1655526dcd2143 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