forked from goodboy/tractor
1
0
Fork 0
tractor/examples/service_discovery.py

21 lines
528 B
Python
Raw Permalink Normal View History

import tractor
tractor.log.get_console_log("INFO")
async def main(service_name):
async with tractor.open_nursery() as an:
await an.start_actor(service_name)
async with tractor.get_arbiter('127.0.0.1', 1616) as portal:
print(f"Arbiter is listening on {portal.channel}")
async with tractor.wait_for_actor(service_name) as sockaddr:
print(f"my_service is found at {sockaddr}")
await an.cancel()
if __name__ == '__main__':
tractor.run(main, 'some_actor_name')