From 9108b6c23ea736239b6a868d49591ff2bdf88e9e Mon Sep 17 00:00:00 2001 From: Case Zumbrum Date: Mon, 10 Feb 2025 19:11:55 -0500 Subject: [PATCH 1/2] DOC: Move warning to save a reference of the ensure_future function to the top of the important tag, mention the TaskGroup.create_task method as a way to avoid needing to save this reference. --- Doc/library/asyncio-future.rst | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Doc/library/asyncio-future.rst b/Doc/library/asyncio-future.rst index 9dce0731411940..473f16f5cced31 100644 --- a/Doc/library/asyncio-future.rst +++ b/Doc/library/asyncio-future.rst @@ -51,12 +51,14 @@ Future Functions .. important:: - 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. + See also the :func:`create_task` function which is the + preferred way for creating new Tasks or + :meth:`asyncio.TaskGroup.create_task`, an alternative + which keeps the reference within the :class:`asyncio.TaskGroup`. + .. versionchanged:: 3.5.1 The function accepts any :term:`awaitable` object. From e07df0f8dafcd132eed3abdf3eaae36de8cfa054 Mon Sep 17 00:00:00 2001 From: Kumar Aditya Date: Sun, 13 Apr 2025 13:11:47 +0530 Subject: [PATCH 2/2] Update Doc/library/asyncio-future.rst --- Doc/library/asyncio-future.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Doc/library/asyncio-future.rst b/Doc/library/asyncio-future.rst index 473f16f5cced31..32771ba72e0002 100644 --- a/Doc/library/asyncio-future.rst +++ b/Doc/library/asyncio-future.rst @@ -55,9 +55,8 @@ Future Functions a task disappearing mid-execution. See also the :func:`create_task` function which is the - preferred way for creating new Tasks or - :meth:`asyncio.TaskGroup.create_task`, an alternative - which keeps the reference within the :class:`asyncio.TaskGroup`. + preferred way for creating new tasks or use :class:`asyncio.TaskGroup` + which keeps reference to the task internally. .. versionchanged:: 3.5.1 The function accepts any :term:`awaitable` object.