tractor/examples/actor_spawning_and_causalit...

25 lines
494 B
Python
Raw Permalink Normal View History

2021-02-24 18:39:14 +00:00
import trio
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.
"""
# spawn a subactor, run ``cellar_door()`` as its lone task,
# block until its result arrives and the subactor is reaped.
print(
await tractor.to_actor.run(
cellar_door,
name='some_linguist',
)
)
if __name__ == '__main__':
2021-02-24 18:39:14 +00:00
trio.run(main)