Skip to content

Commit c750adb

Browse files
Save a reference for ensure_future and create_task (GH-29163)
Co-authored-by: Joannah Nanjekye <[email protected]>
1 parent 6c5a312 commit c750adb

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

Doc/library/asyncio-future.rst

+3
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ Future Functions
5454
See also the :func:`create_task` function which is the
5555
preferred way for creating new Tasks.
5656

57+
Save a reference to the result of this function, to avoid
58+
a task disappearing mid execution.
59+
5760
.. versionchanged:: 3.5.1
5861
The function accepts any :term:`awaitable` object.
5962

Doc/library/asyncio-task.rst

+5
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,11 @@ Creating Tasks
271271
task = asyncio.ensure_future(coro())
272272
...
273273

274+
.. important::
275+
276+
Save a reference to the result of this function, to avoid
277+
a task disappearing mid execution.
278+
274279
.. versionadded:: 3.7
275280

276281
.. versionchanged:: 3.8

0 commit comments

Comments
 (0)