forked from goodboy/tractor
1
0
Fork 0

Do module abspath loading in actor init

try_trip^2
Tyler Goodlet 2020-01-20 11:04:36 -05:00
parent afa640dcab
commit 91c3716968
1 changed files with 8 additions and 3 deletions

View File

@ -10,7 +10,6 @@ import inspect
import uuid import uuid
import typing import typing
from typing import Dict, List, Tuple, Any, Optional from typing import Dict, List, Tuple, Any, Optional
from types import ModuleType
import sys import sys
import os import os
@ -169,7 +168,7 @@ class Actor:
def __init__( def __init__(
self, self,
name: str, name: str,
rpc_module_paths: Dict[str, ModuleType] = {}, rpc_module_paths: List[str] = {},
statespace: Optional[Dict[str, Any]] = None, statespace: Optional[Dict[str, Any]] = None,
uid: str = None, uid: str = None,
loglevel: str = None, loglevel: str = None,
@ -177,7 +176,13 @@ class Actor:
) -> None: ) -> None:
self.name = name self.name = name
self.uid = (name, uid or str(uuid.uuid4())) self.uid = (name, uid or str(uuid.uuid4()))
self.rpc_module_paths = rpc_module_paths
mods = {}
for path in rpc_module_paths or ():
mod = importlib.import_module(path)
mods[path] = mod.__file__
self.rpc_module_paths = mods
self._mods: dict = {} self._mods: dict = {}
# TODO: consider making this a dynamically defined # TODO: consider making this a dynamically defined