You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/changelog.rst
+19-4Lines changed: 19 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,17 +4,32 @@ Changelog
4
4
5
5
`CalVer, YY.month.patch <https://calver.org/>`_
6
6
7
-
Future
8
-
======
9
-
- :ref:`ASYNC101 <async101>` and :ref:`ASYNC119 <async119>` are now silenced for decorators in :ref:`transform-async-generator-decorators`
7
+
24.11.4
8
+
=======
9
+
- :ref:`ASYNC100 <async100>` once again ignores :func:`trio.open_nursery` and :func:`anyio.create_task_group`, unless we find a call to ``.start_soon()``.
10
+
11
+
24.11.3
12
+
=======
13
+
- Revert :ref:`ASYNC100 <async100>` ignoring :func:`trio.open_nursery` and :func:`anyio.create_task_group` due to it not viewing ``.start_soon()`` as introducing a :ref:`cancel point <cancel_point>`.
14
+
15
+
24.11.2
16
+
=======
17
+
- Fix crash in ``Visitor91x`` on ``async with a().b():``.
18
+
19
+
24.11.1
20
+
=======
21
+
- :ref:`ASYNC100 <async100>` now ignores :func:`trio.open_nursery` and :func:`anyio.create_task_group`
22
+
as cancellation sources, because they are :ref:`schedule points <schedule_point>` but not
23
+
:ref:`cancellation points <cancel_point>`.
24
+
- :ref:`ASYNC101 <async101>` and :ref:`ASYNC119 <async119>` are now silenced for decorators in :ref:`transform-async-generator-decorators`.
10
25
11
26
24.10.2
12
27
=======
13
28
- :ref:`ASYNC102 <async102>` now also warns about ``await()`` inside ``__aexit__``.
Copy file name to clipboardExpand all lines: docs/glossary.rst
+32-5Lines changed: 32 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -88,8 +88,8 @@ Exception classes:
88
88
89
89
Checkpoint
90
90
----------
91
-
Checkpoints are points where the async backend checks for cancellation and
92
-
can switch which task is running, in an ``await``, ``async for``, or ``async with``
91
+
Checkpoints are points where the async backend checks for :ref:`cancellation<cancel_point>` and
92
+
:ref:`can switch which task is running<schedule_point>`, in an ``await``, ``async for``, or ``async with``
93
93
expression. Regular checkpoints can be important for both performance and correctness.
94
94
95
95
Trio has extensive and detailed documentation on the concept of
@@ -99,11 +99,11 @@ functions defined by Trio will either checkpoint or raise an exception when
99
99
iteration, and when exhausting the iterator, and ``async with`` will checkpoint
100
100
on at least one of enter/exit.
101
101
102
+
The one exception is :func:`trio.open_nursery` and :func:`anyio.create_task_group`. They do not checkpoint on entry, and on exit they insert a :ref:`schedule point <schedule_point>`. However, if sub-tasks are cancelled they will be propagated on exit, so if you're starting tasks you can usually treat the exit as a :ref:`cancel point <cancel_point>`.
103
+
102
104
asyncio does not place any guarantees on if or when asyncio functions will
103
105
checkpoint. This means that enabling and adhering to :ref:`ASYNC91x <ASYNC910>`
104
-
will still not guarantee checkpoints.
105
-
106
-
For anyio it will depend on the current backend.
106
+
will still not guarantee checkpoints on asyncio (even if used via anyio).
107
107
108
108
When using Trio (or an AnyIO library that people might use on Trio), it can be
109
109
very helpful to ensure that your own code adheres to the same guarantees as
@@ -116,6 +116,33 @@ To insert a checkpoint with no other side effects, you can use
A schedule point is half of a full :ref:`checkpoint`, which allows the async backend to switch the running task, but doesn't check for cancellation (the other half is a :ref:`cancel_point`).
124
+
While you are unlikely to need one, they are available as :func:`trio.lowlevel.cancel_shielded_checkpoint`/:func:`anyio.lowlevel.cancel_shielded_checkpoint`, and equivalent to
125
+
126
+
.. code-block:: python
127
+
128
+
from trio import CancelScope, lowlevel
129
+
# or
130
+
# from anyio import CancelScope, lowlevel
131
+
132
+
with CancelScope(shield=True):
133
+
await lowlevel.checkpoint()
134
+
135
+
asyncio does not have any direct equivalents due to their cancellation model being different.
136
+
137
+
138
+
.. _cancel_point:
139
+
140
+
Cancel Point
141
+
------------
142
+
A schedule point is half of a full :ref:`checkpoint`, which will raise :ref:`cancelled` if the enclosing cancel scope has been cancelled, but does not allow the scheduler to switch to a different task (the other half is a :ref:`schedule_point`).
143
+
While you are unlikely to need one, they are available as :func:`trio.lowlevel.checkpoint_if_cancelled`/:func:`anyio.lowlevel.checkpoint_if_cancelled`.
144
+
Users of asyncio might want to use :meth:`asyncio.Task.cancelled`.
A :ref:`timeout_context` does not contain any :ref:`checkpoints <checkpoint>`.
14
14
This makes it pointless, as the timeout can only be triggered by a checkpoint.
15
15
This check also treats ``yield`` as a checkpoint, since checkpoints can happen in the caller we yield to.
16
+
:func:`trio.open_nursery` and :func:`anyio.create_task_group` are excluded, as they are :ref:`schedule points <schedule_point>` but not :ref:`cancel points <cancel_point>` (unless they have tasks started in them).
16
17
See :ref:`ASYNC912 <async912>` which will in addition guarantee checkpoints on every code path.
0 commit comments