Skip to content

[3.10] Save a reference for ensure_future and create_task (GH-29163) #29572

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Doc/library/asyncio-future.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
5 changes: 5 additions & 0 deletions Doc/library/asyncio-task.rst
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,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
Expand Down