forked from goodboy/tractor
Propagate `tractor.run()` logging level to subactors
parent
4b825778dd
commit
4e078368fc
|
@ -10,7 +10,7 @@ import typing
|
||||||
import trio # type: ignore
|
import trio # type: ignore
|
||||||
from trio import MultiError
|
from trio import MultiError
|
||||||
|
|
||||||
from .log import get_console_log, get_logger, get_loglevel
|
from . import log
|
||||||
from ._ipc import _connect_chan, Channel, Context
|
from ._ipc import _connect_chan, Channel, Context
|
||||||
from ._actor import (
|
from ._actor import (
|
||||||
Actor, _start_actor, Arbiter, get_arbiter, find_actor, wait_for_actor
|
Actor, _start_actor, Arbiter, get_arbiter, find_actor, wait_for_actor
|
||||||
|
@ -51,11 +51,14 @@ async def _main(
|
||||||
) -> typing.Any:
|
) -> typing.Any:
|
||||||
"""Async entry point for ``tractor``.
|
"""Async entry point for ``tractor``.
|
||||||
"""
|
"""
|
||||||
log = get_logger('tractor')
|
logger = log.get_logger('tractor')
|
||||||
main = partial(async_fn, *args)
|
main = partial(async_fn, *args)
|
||||||
arbiter_addr = (host, port) = arbiter_addr or (
|
arbiter_addr = (host, port) = arbiter_addr or (
|
||||||
_default_arbiter_host, _default_arbiter_port)
|
_default_arbiter_host, _default_arbiter_port)
|
||||||
get_console_log(kwargs.get('loglevel', get_loglevel()))
|
loglevel = kwargs.get('loglevel', log.get_loglevel())
|
||||||
|
if loglevel is not None:
|
||||||
|
log._default_loglevel = loglevel
|
||||||
|
log.get_console_log(loglevel)
|
||||||
|
|
||||||
# make a temporary connection to see if an arbiter exists
|
# make a temporary connection to see if an arbiter exists
|
||||||
arbiter_found = False
|
arbiter_found = False
|
||||||
|
@ -63,11 +66,11 @@ async def _main(
|
||||||
async with _connect_chan(host, port):
|
async with _connect_chan(host, port):
|
||||||
arbiter_found = True
|
arbiter_found = True
|
||||||
except OSError:
|
except OSError:
|
||||||
log.warning(f"No actor could be found @ {host}:{port}")
|
logger.warning(f"No actor could be found @ {host}:{port}")
|
||||||
|
|
||||||
# create a local actor and start up its main routine/task
|
# create a local actor and start up its main routine/task
|
||||||
if arbiter_found: # we were able to connect to an arbiter
|
if arbiter_found: # we were able to connect to an arbiter
|
||||||
log.info(f"Arbiter seems to exist @ {host}:{port}")
|
logger.info(f"Arbiter seems to exist @ {host}:{port}")
|
||||||
actor = Actor(
|
actor = Actor(
|
||||||
name or 'anonymous',
|
name or 'anonymous',
|
||||||
arbiter_addr=arbiter_addr,
|
arbiter_addr=arbiter_addr,
|
||||||
|
|
|
@ -112,6 +112,7 @@ class ActorNursery:
|
||||||
rpc_module_paths=[mod_path] + rpc_module_paths,
|
rpc_module_paths=[mod_path] + rpc_module_paths,
|
||||||
bind_addr=bind_addr,
|
bind_addr=bind_addr,
|
||||||
statespace=statespace,
|
statespace=statespace,
|
||||||
|
loglevel=loglevel,
|
||||||
)
|
)
|
||||||
# this marks the actor to be cancelled after its portal result
|
# this marks the actor to be cancelled after its portal result
|
||||||
# is retreived, see ``wait()`` below.
|
# is retreived, see ``wait()`` below.
|
||||||
|
|
Loading…
Reference in New Issue