From: Joannah Nanjekye <33177550+nanjekyejoannah@users.noreply.github.com> Date: Mon, 15 Nov 2021 22:30:28 +0000 (-0400) Subject: Save a reference for ensure_future and create_task (GH-29163) X-Git-Tag: v3.11.0a3~244 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c750adbe6990ee8239b27d5f4591283a06bfe862;p=thirdparty%2FPython%2Fcpython.git Save a reference for ensure_future and create_task (GH-29163) Co-authored-by: Joannah Nanjekye --- diff --git a/Doc/library/asyncio-future.rst b/Doc/library/asyncio-future.rst index ef496a23f5cd..3496387c178a 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 07354e028b12..36e13f929565 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