]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Save a reference for ensure_future and create_task (GH-29163)
authorJoannah Nanjekye <33177550+nanjekyejoannah@users.noreply.github.com>
Mon, 15 Nov 2021 22:30:28 +0000 (18:30 -0400)
committerGitHub <noreply@github.com>
Mon, 15 Nov 2021 22:30:28 +0000 (14:30 -0800)
Co-authored-by: Joannah Nanjekye <jnanjekye@python.org>
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 07354e028b12a897b05b8494357bbb31ba49d8e6..36e13f929565231e18b63700e5ca1254dcbbbc98 100644 (file)
@@ -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