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

Deprecate tractor.run() #179

Merged
merged 0 commits into from
Dec 27, 2020
Merged

Deprecate tractor.run() #179

merged 0 commits into from
Dec 27, 2020

Conversation

goodboy
Copy link
Owner

@goodboy goodboy commented Dec 27, 2020

Starting work toward dropping tractor.run() as it pertains to #168 and #177.

The ideal user facing API instead looks like:

import trio
import tractor

async def main():

    # actor runtime is started implicitly inside the first used nursery if this actor is the root
    async with tractor.open_nursery() as n:
        portal = await n.run_in_actor(trio.sleep(1))
        
trio.run(main)

or, if the user wants to start up the actor runtime / tree manually:

import trio
import tractor

async def main():

    # this starts up the IPC / channel machinery without having to open an actor nursery.
    # you could also just open an actor nursery and sleep in it's body I guess?
    async with tractor.open_root_actor() as actor:
        # run a top level root actor and that's it.
        await trio.sleep_forever()
        
trio.run(main)

Would appreciate thoughts @richardsheridan when you get a chance.

@goodboy goodboy merged commit eb088cd into infect_asyncio Dec 27, 2020
@goodboy goodboy deleted the drop_tractor_run branch December 27, 2020 18:06
@goodboy goodboy restored the drop_tractor_run branch December 27, 2020 18:07
@goodboy
Copy link
Owner Author

goodboy commented Dec 27, 2020

Yeah, sorry this one got auto-merged during rebase onto master.
New PR is #181.

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 this pull request may close these issues.

1 participant