-
-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #375 from njsmith/simplified-nurseries
Simplified nurseries
- Loading branch information
Showing
11 changed files
with
279 additions
and
604 deletions.
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.