Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

bpo-46752: Slight improvements to TaskGroup API#31398

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
gvanrossum merged 3 commits intopython:mainfromgvanrossum:rm-tg-name
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
NextNext commit
Remove task group names (for now)
We're not sure that they are needed, and once in the codewe 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.
  • Loading branch information
@gvanrossum
gvanrossum committedFeb 17, 2022
commit32468ef98e0e8c9e83fe9d738571b886774d5c43
12 changes: 2 additions & 10 deletionsLib/asyncio/taskgroups.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,12 +15,7 @@

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
Expand All@@ -33,11 +28,8 @@ def __init__(self, *, name=None):
self._base_error = None
self._on_completed_fut = None

def get_name(self):
return self._name

def __repr__(self):
msg = f'<TaskGroup {self._name!r}'
msg = f'<TaskGroup'
if self._tasks:
msg += f' tasks:{len(self._tasks)}'
if self._unfinished_tasks:
Expand Down
12 changes: 6 additions & 6 deletionsLib/test/test_asyncio/test_taskgroups.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -368,10 +368,10 @@ async def crash_after(t):
raise ValueError(t)

async def runner():
async with taskgroups.TaskGroup(name='g1') as g1:
async with taskgroups.TaskGroup() as g1:
g1.create_task(crash_after(0.1))

async with taskgroups.TaskGroup(name='g2') as g2:
async with taskgroups.TaskGroup() as g2:
g2.create_task(crash_after(0.2))

r = asyncio.create_task(runner())
Expand All@@ -387,10 +387,10 @@ async def crash_after(t):
raise ValueError(t)

async def runner():
async with taskgroups.TaskGroup(name='g1') as g1:
async with taskgroups.TaskGroup() as g1:
g1.create_task(crash_after(10))

async with taskgroups.TaskGroup(name='g2') as g2:
async with taskgroups.TaskGroup() as g2:
g2.create_task(crash_after(0.1))

r = asyncio.create_task(runner())
Expand All@@ -407,7 +407,7 @@ async def crash_soon():
1 / 0

async def runner():
async with taskgroups.TaskGroup(name='g1') as g1:
async with taskgroups.TaskGroup() as g1:
g1.create_task(crash_soon())
try:
await asyncio.sleep(10)
Expand All@@ -430,7 +430,7 @@ async def crash_soon():
1 / 0

async def nested_runner():
async with taskgroups.TaskGroup(name='g1') as g1:
async with taskgroups.TaskGroup() as g1:
g1.create_task(crash_soon())
try:
await asyncio.sleep(10)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp