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

start() shouldn't support multiple tasks in the old_nursery #1599

Open
oremanj opened this issue Jun 10, 2020 · 0 comments · May be fixed by #1600
Open

start() shouldn't support multiple tasks in the old_nursery #1599

oremanj opened this issue Jun 10, 2020 · 0 comments · May be fixed by #1600

Comments

@oremanj
Copy link
Member

oremanj commented Jun 10, 2020

Currently, Nursery.start() is implemented internally by opening a private nursery and starting the new task there, and TaskStatus.started() moves all tasks from that private nursery (the "old_nursery") to the task's final home ("new_nursery", the nursery whose start() method was called). In theory, there should only be one task in the old nursery, since the nursery isn't exposed anywhere outside the body of start() for anyone to be able to start more. In practice, it's possible to access the old nursery via current_task().parent_nursery in the newly-started task, so we may have some users who are starting more tasks there, maybe not even realizing that it's not the same nursery on which start() was called. This currently works fine, but it's confusing and makes it hard to implement extensions to the nursery semantics such as #1521.

Since this works now, we probably want a deprecation period. The purpose of this issue is mostly to have a number to put in the deprecation message. If your code runs into this, ideally you would refactor it to pass a nursery around explicitly rather than assuming you can always start new tasks in your parent nursery. If that's not possible for some reason, you can use task.eventual_parent_nursery or task.parent_nursery to determine the parent nursery that will prevail once the start() call completes.

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

Successfully merging a pull request may close this issue.

1 participant