diff --git a/tractor/_discovery.py b/tractor/_discovery.py index 3667c90..0407896 100644 --- a/tractor/_discovery.py +++ b/tractor/_discovery.py @@ -23,6 +23,7 @@ async def get_arbiter( arbiter. """ actor = current_actor() + if not actor: raise RuntimeError("No actor instance has been defined yet?") @@ -38,7 +39,8 @@ async def get_arbiter( @asynccontextmanager async def find_actor( - name: str, arbiter_sockaddr: Tuple[str, int] = None + name: str, + arbiter_sockaddr: Tuple[str, int] = None ) -> typing.AsyncGenerator[Optional[Portal], None]: """Ask the arbiter to find actor(s) by name. diff --git a/tractor/_entry.py b/tractor/_entry.py index 1ccc0b5..883cc6b 100644 --- a/tractor/_entry.py +++ b/tractor/_entry.py @@ -72,8 +72,10 @@ def _trio_main( actor._async_main, parent_addr=parent_addr ) + try: trio.run(trio_main) except KeyboardInterrupt: - pass # handle it the same way trio does? - log.info(f"Actor {actor.uid} terminated") \ No newline at end of file + log.warning(f"Actor {actor.uid} received KBI") + + log.info(f"Actor {actor.uid} terminated")