From 3a5cd50f10d8de6d0089afa2401a181866c6af19 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Mon, 19 May 2025 21:17:28 -0400 Subject: [PATCH 1/3] Update what's new in 3.13 and 3.14 with create_task changes --- Doc/whatsnew/3.13.rst | 14 ++++++++++++++ Doc/whatsnew/3.14.rst | 17 +++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst index 023c279979d842..847933961e565f 100644 --- a/Doc/whatsnew/3.13.rst +++ b/Doc/whatsnew/3.13.rst @@ -730,6 +730,20 @@ asyncio never awaited). (Contributed by Arthur Tacca and Jason Zhang in :gh:`115957`.) +* The function and methods named ``create_task`` have received a new + ``**kwargs`` argument that is passed through to the task constructor. + This changed was accidentally added in 3.13.3, + and broke the API contract for custom task factories. + Several third-party task factories implemented workarounds for this. + In 3.13.4 and later releases the old factory contract is honored + once again (until 3.14), but the extra ``**kwargs`` argument still + allows passing additional keyword arguments to :class:`~asyncio.Task` + and to custom task factories, to keep the workarounds working. + This affects the following function and methods: + :meth:`asyncio.create_task`, + :meth:`asyncio.loop.create_task`, + :meth:`asyncio.TaskGroup.create_task`. + (Contributed by Thomas Grainger in :gh:`128307`.) base64 ------ diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index 8f39b99e38e3a5..14b77b3c893d7f 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -1064,6 +1064,23 @@ ast (Contributed by Semyon Moroz in :gh:`133367`.) +asyncio +------- + +* The function and methods named ``create_task`` now take an arbitrary + list of keyword arguments. All keyword arguments are passed to the + :class:`~asyncio.Task` constructor or the custom task factory. + (See :meth:`~asyncio.loop.set_task_factory` for details.) + Keywords ``name`` and ``context`` are no longer special; the name + should now be set using the ``name`` keyword argument of the factory, + and ``context`` may be ``None``. + This affects the following function and methods: + :meth:`asyncio.create_task`, + :meth:`asyncio.loop.create_task`, + :meth:`asyncio.TaskGroup.create_task`. + (Contributed by Thomas Grainger in :gh:`128307`.) + + bdb --- From 56526debaabad8cd98b261fde43f93b12f4199f4 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Mon, 19 May 2025 21:28:39 -0400 Subject: [PATCH 2/3] Typo --- Doc/whatsnew/3.13.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst index 847933961e565f..5a56617e4c8bbf 100644 --- a/Doc/whatsnew/3.13.rst +++ b/Doc/whatsnew/3.13.rst @@ -732,7 +732,7 @@ asyncio * The function and methods named ``create_task`` have received a new ``**kwargs`` argument that is passed through to the task constructor. - This changed was accidentally added in 3.13.3, + This change was accidentally added in 3.13.3, and broke the API contract for custom task factories. Several third-party task factories implemented workarounds for this. In 3.13.4 and later releases the old factory contract is honored From c82a63bd4860c26eba52c22edeefd6a056ab3cbd Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Mon, 19 May 2025 18:38:41 -0700 Subject: [PATCH 3/3] Apply suggestions from review by Adam Turner Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> --- Doc/whatsnew/3.13.rst | 6 ++++-- Doc/whatsnew/3.14.rst | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst index 5a56617e4c8bbf..580a3d8154dee1 100644 --- a/Doc/whatsnew/3.13.rst +++ b/Doc/whatsnew/3.13.rst @@ -736,9 +736,11 @@ asyncio and broke the API contract for custom task factories. Several third-party task factories implemented workarounds for this. In 3.13.4 and later releases the old factory contract is honored - once again (until 3.14), but the extra ``**kwargs`` argument still + once again (until 3.14). + To keep the workarounds working, the extra ``**kwargs`` argument still allows passing additional keyword arguments to :class:`~asyncio.Task` - and to custom task factories, to keep the workarounds working. + and to custom task factories. + This affects the following function and methods: :meth:`asyncio.create_task`, :meth:`asyncio.loop.create_task`, diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index 14b77b3c893d7f..b192615e173f11 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -1067,13 +1067,14 @@ ast asyncio ------- -* The function and methods named ``create_task`` now take an arbitrary +* The function and methods named :func:`!create_task` now take an arbitrary list of keyword arguments. All keyword arguments are passed to the :class:`~asyncio.Task` constructor or the custom task factory. (See :meth:`~asyncio.loop.set_task_factory` for details.) - Keywords ``name`` and ``context`` are no longer special; the name - should now be set using the ``name`` keyword argument of the factory, + The ``name`` and ``context`` keyword arguments are no longer special; + the name should now be set using the ``name`` keyword argument of the factory, and ``context`` may be ``None``. + This affects the following function and methods: :meth:`asyncio.create_task`, :meth:`asyncio.loop.create_task`,