-
-
Notifications
You must be signed in to change notification settings - Fork 338
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
Simplified nurseries #375
Merged
Merged
Simplified nurseries #375
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
**Simplified nurseries**: In Trio, the rule used to be that "parenting | ||
is a full time job", meaning that after a task opened a nursery and | ||
spawned some children into it, it had to immediately block in | ||
``__aexit__`` to supervise the new children, or else exception | ||
propagation wouldn't work. Also there was some elaborate machinery to | ||
let you replace this supervision logic with your own custom | ||
supervision logic. Thanks to new advances in task-rearing technology, | ||
**parenting is no longer a full time job!** Now the supervision happens | ||
automatically in the background, and essentially the body of a ``async | ||
with trio.open_nursery()`` block acts just like a task running inside | ||
the nursery. This is important: it makes it possible for libraries to | ||
abstract over nursery creation. For example, if you have a Websocket | ||
library that needs to run a background task to handle Websocket pings, | ||
you can now do that with ``async with open_websocket(...) as ws: | ||
...``, and that can run a task in the background without your users | ||
having to worry about parenting it. And don't worry, you can still | ||
make custom supervisors; it turned out all that spiffy machinery was | ||
actually redundant and didn't provide much value. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC this should run after the loop, not inside it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch! Fixed.