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

Idea: unbound nurseries? #1597

Open
oremanj opened this issue Jun 9, 2020 · 0 comments
Open

Idea: unbound nurseries? #1597

oremanj opened this issue Jun 9, 2020 · 0 comments

Comments

@oremanj
Copy link
Member

oremanj commented Jun 9, 2020

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 with block.
  • If you call start_soon() before the async with block is entered, the Task is still created but it's not added to the runq yet.
  • If you call start() before the async with block is entered, the new task starts up like normal, but blocks at its first checkpoint after started() 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant