Skip to content

Commit 451393a

Browse files
authored
[docs] clarify checkpoint semantics for trio.open_nursery (#3011)
* clarify checkpoint semantics for trio.open_nursery * clarify what schedule-but-no-cancellation-point means for nurseries
1 parent 0f5fc6c commit 451393a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

docs/source/reference-core.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ them. Here are the rules:
102102
only that one will act as a checkpoint. This is documented
103103
on a case-by-case basis.
104104

105+
* :func:`trio.open_nursery` is a further exception to this rule.
106+
105107
* Third-party async functions / iterators / context managers can act
106108
as checkpoints; if you see ``await <something>`` or one of its
107109
friends, then that *might* be a checkpoint. So to be safe, you

src/trio/_core/_run.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,11 @@ def open_nursery(
986986
new `Nursery`.
987987
988988
It does not block on entry; on exit it blocks until all child tasks
989-
have exited.
989+
have exited. If no child tasks are running on exit, it will insert a
990+
schedule point (but no cancellation point) - equivalent to
991+
:func:`trio.lowlevel.cancel_shielded_checkpoint`. This means a nursery
992+
is never the source of a cancellation exception, it only propagates it
993+
from sub-tasks.
990994
991995
Args:
992996
strict_exception_groups (bool): Unless set to False, even a single raised exception

0 commit comments

Comments
 (0)