Skip to content

gh-155502: Warn about keeping a reference to tasks from loop.create_task - #155599

Draft
Khan3K wants to merge 1 commit into
python:mainfrom
Khan3K:asyncio-loop-create-task-docs
Draft

gh-155502: Warn about keeping a reference to tasks from loop.create_task#155599
Khan3K wants to merge 1 commit into
python:mainfrom
Khan3K:asyncio-loop-create-task-docs

Conversation

@Khan3K

@Khan3K Khan3K commented Aug 12, 2026

Copy link
Copy Markdown

The high-level :func:asyncio.create_task documentation warns that the event loop only keeps weak references to tasks and that unreferenced tasks may be garbage collected before they finish, but the low-level :meth:asyncio.loop.create_task documentation did not repeat this warning.

This mirrors the warning (including the "fire-and-forget" collection pattern and the :class:asyncio.TaskGroup alternative) in the :meth:asyncio.loop.create_task documentation, using loop.create_task in the example.

Linked PRs

…eate_task

The low-level Event Loop documentation for create_task() did not repeat
the warning from the high-level asyncio.create_task() docs that the
event loop only keeps weak references to tasks, so a task that is not
referenced elsewhere may be garbage collected before it completes.
Mirror the note (including the fire-and-forget collection pattern) in
the loop.create_task() documentation.
@python-cla-bot

Copy link
Copy Markdown

The following commit authors need to sign the Contributor License Agreement:

CLA not signed

@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #34025502 | 📁 Comparing eb70da4 against main (ee68f5f)

  🔍 Preview build  

1 file changed
± library/asyncio-eventloop.html

@StanFromIreland

Copy link
Copy Markdown
Member

You must sign the CLA before we can review.

@StanFromIreland
StanFromIreland marked this pull request as draft August 12, 2026 09:11
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: Todo

Development

Successfully merging this pull request may close these issues.

3 participants