Skip to content

gh-129169: Update docs on asyncio.ensure_future() to make it more clear that a reference of the returned value should be stored and provide an alternative to avoid this. #129986

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 3 commits into from
Apr 13, 2025

Conversation

CaseZumbrum
Copy link
Contributor

@CaseZumbrum CaseZumbrum commented Feb 11, 2025

Linked Issue

Resolves #129169

Problem Summary

Documentation for the asyncio.ensure_future() function was not clear that the output of the function needs to be saved to avoid the task being deleted.

Solution

Made this more explicit by moving this warning to the top of the "important" tag of the function, provided an alternative (TaskGroup) that would not require the saving of the task to a variable.


📚 Documentation preview 📚: https://cpython-previews--129986.org.readthedocs.build/

…o the top of the important tag, mention the TaskGroup.create_task method as a way to avoid needing to save this reference.
@ghost
Copy link

ghost commented Feb 11, 2025

All commit authors signed the Contributor License Agreement.
CLA signed

Copy link

@auvipy auvipy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the change seems to be OK

@kumaraditya303 kumaraditya303 enabled auto-merge (squash) April 13, 2025 07:42
@kumaraditya303 kumaraditya303 merged commit 00cf5ea into python:main Apr 13, 2025
24 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in Docs PRs Apr 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip news
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Doc unclear that ensure_future should also have its referenced saved somewhere
3 participants