2020-07-20 19:18:38 +00:00
|
|
|
import sys
|
|
|
|
import trio
|
2020-07-27 17:55:37 +00:00
|
|
|
import argparse
|
|
|
|
|
2020-07-28 00:05:00 +00:00
|
|
|
from ast import literal_eval
|
|
|
|
|
2020-07-27 17:55:37 +00:00
|
|
|
from ._actor import Actor
|
|
|
|
from ._entry import _trio_main
|
|
|
|
|
|
|
|
|
2020-07-28 00:05:00 +00:00
|
|
|
"""This is the "bootloader" for actors started using the native trio backend.
|
2020-07-27 17:55:37 +00:00
|
|
|
"""
|
|
|
|
|
2020-07-28 00:05:00 +00:00
|
|
|
def parse_uid(arg):
|
|
|
|
uid = literal_eval(arg)
|
|
|
|
assert len(uid) == 2
|
|
|
|
assert isinstance(uid[0], str)
|
|
|
|
assert isinstance(uid[1], str)
|
|
|
|
return uid
|
|
|
|
|
|
|
|
def parse_ipaddr(arg):
|
|
|
|
addr = literal_eval(arg)
|
|
|
|
assert len(addr) == 2
|
|
|
|
assert isinstance(addr[0], str)
|
|
|
|
assert isinstance(addr[1], int)
|
|
|
|
return addr
|
|
|
|
|
2020-07-20 19:18:38 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2020-07-27 17:55:37 +00:00
|
|
|
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
|
2020-07-28 00:05:00 +00:00
|
|
|
parser.add_argument("--uid", type=parse_uid)
|
|
|
|
parser.add_argument("--loglevel", type=str)
|
|
|
|
parser.add_argument("--parent_addr", type=parse_ipaddr)
|
2020-07-27 17:55:37 +00:00
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
subactor = Actor(
|
2020-07-28 00:05:00 +00:00
|
|
|
args.uid[0],
|
|
|
|
uid=args.uid[1],
|
|
|
|
loglevel=args.loglevel,
|
|
|
|
spawn_method="trio"
|
|
|
|
)
|
2020-07-27 17:55:37 +00:00
|
|
|
|
|
|
|
_trio_main(
|
|
|
|
subactor,
|
2020-07-28 00:05:00 +00:00
|
|
|
("127.0.0.1", 0),
|
|
|
|
parent_addr=args.parent_addr
|
2020-07-27 17:55:37 +00:00
|
|
|
)
|