[3.13] gh-128308: pass **kwargs to asyncio task_factory (GH-128768) (#130084)

* [3.13] gh-128308: pass `**kwargs` to asyncio task_factory (GH-128768)
(cherry picked from commit 38a9956876)

Co-authored-by: Thomas Grainger <tagrain@gmail.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>


---------

Co-authored-by: Thomas Grainger <tagrain@gmail.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
This commit is contained in:
Andrew Svetlov 2025-02-14 17:34:17 +01:00 committed by GitHub
parent 9e23e0ad2c
commit 7b0543ebe6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 40 additions and 21 deletions

View file

@ -1081,6 +1081,18 @@ class BaseTestTaskGroup:
# cancellation happens here and error is more understandable
await asyncio.sleep(0)
async def test_name(self):
name = None
async def asyncfn():
nonlocal name
name = asyncio.current_task().get_name()
async with asyncio.TaskGroup() as tg:
tg.create_task(asyncfn(), name="example name")
self.assertEqual(name, "example name")
class TestTaskGroup(BaseTestTaskGroup, unittest.IsolatedAsyncioTestCase):
loop_factory = asyncio.EventLoop