forked from goodboy/tractor
Enforce async funcs on callee side, convert arbiter methods
parent
c2a1612bf5
commit
5798ef6796
|
@ -64,12 +64,13 @@ async def _invoke(
|
||||||
kwargs['ctx'] = ctx
|
kwargs['ctx'] = ctx
|
||||||
treat_as_gen = True
|
treat_as_gen = True
|
||||||
|
|
||||||
|
# errors raised inside this block are propgated back to caller
|
||||||
try:
|
try:
|
||||||
is_async_partial = False
|
if not (
|
||||||
is_async_gen_partial = False
|
inspect.isasyncgenfunction(func) or
|
||||||
if isinstance(func, partial):
|
inspect.iscoroutinefunction(func)
|
||||||
is_async_partial = inspect.iscoroutinefunction(func.func)
|
):
|
||||||
is_async_gen_partial = inspect.isasyncgenfunction(func.func)
|
raise TypeError(f'{func} must be an async function!')
|
||||||
|
|
||||||
coro = func(**kwargs)
|
coro = func(**kwargs)
|
||||||
|
|
||||||
|
@ -1036,7 +1037,7 @@ class Arbiter(Actor):
|
||||||
self._waiters = {}
|
self._waiters = {}
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
def find_actor(self, name: str) -> Optional[Tuple[str, int]]:
|
async def find_actor(self, name: str) -> Optional[Tuple[str, int]]:
|
||||||
for uid, sockaddr in self._registry.items():
|
for uid, sockaddr in self._registry.items():
|
||||||
if name in uid:
|
if name in uid:
|
||||||
return sockaddr
|
return sockaddr
|
||||||
|
@ -1077,7 +1078,7 @@ class Arbiter(Actor):
|
||||||
|
|
||||||
return sockaddrs
|
return sockaddrs
|
||||||
|
|
||||||
def register_actor(
|
async def register_actor(
|
||||||
self, uid: Tuple[str, str], sockaddr: Tuple[str, int]
|
self, uid: Tuple[str, str], sockaddr: Tuple[str, int]
|
||||||
) -> None:
|
) -> None:
|
||||||
name, uuid = uid
|
name, uuid = uid
|
||||||
|
@ -1090,5 +1091,5 @@ class Arbiter(Actor):
|
||||||
if isinstance(event, trio.Event):
|
if isinstance(event, trio.Event):
|
||||||
event.set()
|
event.set()
|
||||||
|
|
||||||
def unregister_actor(self, uid: Tuple[str, str]) -> None:
|
async def unregister_actor(self, uid: Tuple[str, str]) -> None:
|
||||||
self._registry.pop(uid, None)
|
self._registry.pop(uid, None)
|
||||||
|
|
Loading…
Reference in New Issue