python-trio / python-trio/trio
Idea: unbound nurseries?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.3k
- Forks
- 431
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 6
Description
If it was a good idea for cancel scopes (#607)...
I got to thinking about this due to the hoops that #1579 had to jump through. I've also occasionally encountered cases where I wanted to push a nursery into a background task and later spawn things into it, which currently requires an awkward dance with start().
The idea here would be:
- You can construct a nursery just as
trio.Nursery()with no arguments. - The tasks inside the nursery only run once it's bound to an
async withblock. - If you call
start_soon()before theasync withblock is entered, theTaskis still created but it's not added to the runq yet. - If you call
start()before theasync withblock is entered, the new task starts up like normal, but blocks at its first checkpoint afterstarted()until the target nursery is bound.
Is this a good idea at all? If so, are the above semantics the ones we would want?
I'm significantly less convinced this is a good idea for nurseries than that it is one for cancel scopes, especially because "what happens if no one ever binds the nursery?". But I wanted to throw it out there.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review the existing trio.Nursery API and the discussions in issues #607 and #1579. This issue is complete only after the project decides whether unbound nurseries are desirable and defines the binding, start_soon(), start(), and never-bound semantics.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100