summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorJason Zhang <yurenzhang2017@gmail.com>2024-03-06 20:20:26 (GMT)
committerGitHub <noreply@github.com>2024-03-06 20:20:26 (GMT)
commitce0ae1d784871085059a415aa589d9bd16ea8301 (patch)
treeec905cf72732077f8491602fb336b13aea967ae8 /Doc
parent7114cf20c015b99123b32c1ba4f5475b7a6c3a13 (diff)
downloadcpython-ce0ae1d784871085059a415aa589d9bd16ea8301.zip
cpython-ce0ae1d784871085059a415aa589d9bd16ea8301.tar.gz
cpython-ce0ae1d784871085059a415aa589d9bd16ea8301.tar.bz2
gh-115957: Close coroutine if TaskGroup.create_task() raises an error (#116009)
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/asyncio-task.rst7
-rw-r--r--Doc/whatsnew/3.13.rst6
2 files changed, 13 insertions, 0 deletions
diff --git a/Doc/library/asyncio-task.rst b/Doc/library/asyncio-task.rst
index 24bd36e..2aab62c 100644
--- a/Doc/library/asyncio-task.rst
+++ b/Doc/library/asyncio-task.rst
@@ -334,6 +334,13 @@ and reliable way to wait for all tasks in the group to finish.
Create a task in this task group.
The signature matches that of :func:`asyncio.create_task`.
+ If the task group is inactive (e.g. not yet entered,
+ already finished, or in the process of shutting down),
+ we will close the given ``coro``.
+
+ .. versionchanged:: 3.13
+
+ Close the given coroutine if the task group is not active.
Example::
diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst
index 96c8aee..137dbe6 100644
--- a/Doc/whatsnew/3.13.rst
+++ b/Doc/whatsnew/3.13.rst
@@ -185,6 +185,12 @@ Other Language Changes
(Contributed by Sebastian Pipping in :gh:`115623`.)
+* When :func:`asyncio.TaskGroup.create_task` is called on an inactive
+ :class:`asyncio.TaskGroup`, the given coroutine will be closed (which
+ prevents a :exc:`RuntimeWarning` about the given coroutine being
+ never awaited).
+
+ (Contributed by Arthur Tacca and Jason Zhang in :gh:`115957`.)
New Modules
===========