[Django] #36315: use task groups/cancel scopes where possible

9 views
Skip to first unread message

Django

unread,
Apr 10, 2025, 4:32:27 AM4/10/25
to django-...@googlegroups.com
#36315: use task groups/cancel scopes where possible
-------------------------------------------+--------------------------
Reporter: Thomas Grainger | Owner: (none)
Type: Uncategorized | Status: assigned
Component: Uncategorized | Version: dev
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------------+--------------------------
eg replace asyncio.create_task with a Task Group
replace wait_for/wait with Timeout/CancelSceop
create a function for asyncio.gather that uses a Task Group

This could use anyio.create_task_group and anyio.CancelScope, but now
there's 3.11 asyncio.TaskGroup and asyncio.Timeout are available.

Obviously I'm biased and think the anyio versions are a better choice, but
it's easier to add asyncio.TaskGroup/Timeout and worry about trio support
in the 'future'.
--
Ticket URL: <https://code.djangoproject.com/ticket/36315>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 10, 2025, 4:32:45 AM4/10/25
to django-...@googlegroups.com
#36315: use task groups/cancel scopes where possible
-------------------------------------+-------------------------------------
Reporter: Thomas Grainger | Owner: Thomas
| Grainger
Type: Uncategorized | Status: assigned
Component: Uncategorized | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Thomas Grainger):

* owner: (none) => Thomas Grainger


Old description:

> eg replace asyncio.create_task with a Task Group
> replace wait_for/wait with Timeout/CancelSceop
> create a function for asyncio.gather that uses a Task Group
>
> This could use anyio.create_task_group and anyio.CancelScope, but now
> there's 3.11 asyncio.TaskGroup and asyncio.Timeout are available.
>
> Obviously I'm biased and think the anyio versions are a better choice,
> but it's easier to add asyncio.TaskGroup/Timeout and worry about trio
> support in the 'future'.

New description:

eg replace asyncio.create_task with a Task Group
replace wait_for/wait with Timeout/CancelScope
create a function for asyncio.gather that uses a Task Group

This could use anyio.create_task_group and anyio.CancelScope, but now
there's 3.11 asyncio.TaskGroup and asyncio.Timeout are available.

Obviously I'm biased and think the anyio versions are a better choice, but
it's easier to add asyncio.TaskGroup/Timeout and worry about trio support
in the 'future'.

--
--
Ticket URL: <https://code.djangoproject.com/ticket/36315#comment:1>

Django

unread,
Apr 10, 2025, 4:51:02 AM4/10/25
to django-...@googlegroups.com
#36315: use task groups/cancel scopes where possible
-------------------------------------+-------------------------------------
Reporter: Thomas Grainger | Owner: Thomas
| Grainger
Type: Uncategorized | Status: assigned
Component: Uncategorized | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Thomas Grainger):

* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/36315#comment:2>

Django

unread,
Apr 10, 2025, 8:30:55 AM4/10/25
to django-...@googlegroups.com
#36315: use task groups/cancel scopes where possible
-------------------------------------+-------------------------------------
Reporter: Thomas Grainger | Owner: Thomas
Type: | Grainger
Cleanup/optimization | Status: assigned
Component: HTTP handling | Version: dev
Severity: Normal | Resolution:
Keywords: async | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* cc: Carlton Gibson (added)
* component: Uncategorized => HTTP handling
* keywords: => async
* stage: Unreviewed => Accepted
* type: Uncategorized => Cleanup/optimization

Comment:

Yes, this seems like a nice modernisation. Thanks.
--
Ticket URL: <https://code.djangoproject.com/ticket/36315#comment:3>
Reply all
Reply to author
Forward
0 new messages