forked from goodboy/tractor
1
0
Fork 0
tractor/examples/actor_spawning_and_causalit...

27 lines
548 B
Python
Raw Permalink Normal View History

import tractor
2021-04-27 13:14:08 +00:00
async def cellar_door():
assert not tractor.is_root_process()
return "Dang that's beautiful"
async def main():
"""The main ``tractor`` routine.
"""
async with tractor.open_nursery() as n:
portal = await n.run_in_actor(
cellar_door,
name='some_linguist',
)
# The ``async with`` will unblock here since the 'some_linguist'
# actor has completed its main task ``cellar_door``.
print(await portal.result())
if __name__ == '__main__':
tractor.run(main)