2020-07-29 18:39:38 +00:00
|
|
|
"""This is the "bootloader" for actors started using the native trio backend.
|
|
|
|
"""
|
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
|
|
|
def parse_uid(arg):
|
2020-07-28 14:55:11 +00:00
|
|
|
name, uuid = literal_eval(arg) # ensure 2 elements
|
|
|
|
return str(name), str(uuid) # ensures str encoding
|
2020-07-28 00:05:00 +00:00
|
|
|
|
|
|
|
def parse_ipaddr(arg):
|
2020-07-28 14:55:11 +00:00
|
|
|
host, port = literal_eval(arg)
|
|
|
|
return (str(host), int(port))
|
2020-07-28 00:05:00 +00:00
|
|
|
|
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,
|
2020-07-28 14:55:11 +00:00
|
|
|
spawn_method="trio"
|
|
|
|
)
|
2020-07-27 17:55:37 +00:00
|
|
|
|
|
|
|
_trio_main(
|
|
|
|
subactor,
|
2020-07-28 00:05:00 +00:00
|
|
|
parent_addr=args.parent_addr
|
2020-07-27 17:55:37 +00:00
|
|
|
)
|