From d85121660ea50bbe8fbd31797aa6e4afe0850388 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Thu, 17 Feb 2022 21:30:44 -0800 Subject: bpo-46752: Slight improvements to TaskGroup API (GH-31398) * Remove task group names (for now) We're not sure that they are needed, and once in the code we would never be able to get rid of them. Yury wrote: > Ideally, there should be a way for someone to build a "trace" > of taskgroups/task leading to the current running task. > We could do that using contextvars, but I'm not sure we should > do that in 3.11. * Pass optional name on to task in create_task() * Remove a bunch of unused stuff --- Lib/asyncio/taskgroups.py | 22 ++++------------------ Lib/test/test_asyncio/test_taskgroups.py | 19 +++++++++++++------ 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/Lib/asyncio/taskgroups.py b/Lib/asyncio/taskgroups.py index 7182778..57b0eaf 100644 --- a/Lib/asyncio/taskgroups.py +++ b/Lib/asyncio/taskgroups.py @@ -3,10 +3,6 @@ __all__ = ["TaskGroup"] -import itertools -import textwrap -import traceback -import types import weakref from . import events @@ -15,12 +11,7 @@ from . import tasks class TaskGroup: - def __init__(self, *, name=None): - if name is None: - self._name = f'tg-{_name_counter()}' - else: - self._name = str(name) - + def __init__(self): self._entered = False self._exiting = False self._aborting = False @@ -33,11 +24,8 @@ class TaskGroup: self._base_error = None self._on_completed_fut = None - def get_name(self): - return self._name - def __repr__(self): - msg = f'