From e121642180e92eef7898de290ac75ccfc4967cce Mon Sep 17 00:00:00 2001 From: Joannah Nanjekye Date: Fri, 22 Oct 2021 11:35:50 -0300 Subject: [PATCH] Save a reference for ensure_future and create_task --- Doc/library/asyncio-future.rst | 3 +++ Doc/library/asyncio-task.rst | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/Doc/library/asyncio-future.rst b/Doc/library/asyncio-future.rst index ef496a23f5cd4c..3496387c178af7 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 07354e028b12a8..36e13f92956523 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