diff --git a/tractor/_actor.py b/tractor/_actor.py index c9daa81..2e08b12 100644 --- a/tractor/_actor.py +++ b/tractor/_actor.py @@ -768,7 +768,7 @@ async def wait_for_actor( ) -> typing.AsyncGenerator[Portal, None]: """Wait on an actor to register with the arbiter. - A portal to the first actor which registered is be returned. + A portal to the first registered actor is returned. """ actor = current_actor() async with get_arbiter(*arbiter_sockaddr or actor._arb_addr) as arb_portal: diff --git a/tractor/_portal.py b/tractor/_portal.py index f8a01ac..6eaab31 100644 --- a/tractor/_portal.py +++ b/tractor/_portal.py @@ -2,6 +2,7 @@ Portal api """ import importlib +import inspect import typing from typing import Tuple, Any, Dict, Optional @@ -220,7 +221,11 @@ class LocalPortal: """Run a requested function locally and return it's result. """ obj = self.actor if ns == 'self' else importlib.import_module(ns) - return getattr(obj, func)(**kwargs) + func = getattr(obj, func) + if inspect.iscoroutinefunction(func): + return await func(**kwargs) + else: + return func(**kwargs) @asynccontextmanager