-
-
Notifications
You must be signed in to change notification settings - Fork 323
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
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently,
Nursery.start()
is implemented internally by opening a private nursery and starting the new task there, andTaskStatus.started()
moves all tasks from that private nursery (the "old_nursery") to the task's final home ("new_nursery", the nursery whosestart()
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 ofstart()
for anyone to be able to start more. In practice, it's possible to access the old nursery viacurrent_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 thestart()
call completes.The text was updated successfully, but these errors were encountered: