Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] clarify checkpoint semantics for trio.open_nursery #3011

Merged
merged 2 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions docs/source/reference-core.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ them. Here are the rules:
only that one will act as a checkpoint. This is documented
on a case-by-case basis.

* :func:`trio.open_nursery` is a further exception to this rule.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is needed, I think the Partial exception for async context managers block handles this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be overkill, but open_nursery in itself as a context manager doesn't guarantee a full checkpoint on either of entry or exit - so imo it doesn't abide by the special rules in the Partial exception for async context managers block. There's some more discussion around this in #1457


* Third-party async functions / iterators / context managers can act
as checkpoints; if you see ``await <something>`` or one of its
friends, then that *might* be a checkpoint. So to be safe, you
Expand Down
6 changes: 5 additions & 1 deletion src/trio/_core/_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,11 @@ def open_nursery(
new `Nursery`.

It does not block on entry; on exit it blocks until all child tasks
have exited.
have exited. If no child tasks are running on exit, it will insert a
schedule point (but no cancellation point) - equivalent to
:func:`trio.lowlevel.cancel_shielded_checkpoint`. This means a nursery
is never the source of a cancellation exception, it only propagates it
from sub-tasks.

Args:
strict_exception_groups (bool): Unless set to False, even a single raised exception
Expand Down
Loading