forked from goodboy/tractor
Enable `stackscope` render via root in debug mode
If `stackscope` is importable and debug_mode is enabled then we by default call and report `.devx.enable_stack_on_sig()` is set B) This makes debugging unexpected (SIGINT ignoring) hangs a cinch!modden_spawn_from_client_req
parent
54a0a0000d
commit
1d7cf7d1dd
|
@ -138,13 +138,19 @@ async def open_root_actor(
|
||||||
)
|
)
|
||||||
assert registry_addrs
|
assert registry_addrs
|
||||||
|
|
||||||
loglevel = (loglevel or log._default_loglevel).upper()
|
loglevel = (
|
||||||
|
loglevel
|
||||||
|
or log._default_loglevel
|
||||||
|
).upper()
|
||||||
|
|
||||||
if debug_mode and _spawn._spawn_method == 'trio':
|
if (
|
||||||
|
debug_mode
|
||||||
|
and _spawn._spawn_method == 'trio'
|
||||||
|
):
|
||||||
_state._runtime_vars['_debug_mode'] = True
|
_state._runtime_vars['_debug_mode'] = True
|
||||||
|
|
||||||
# expose internal debug module to every actor allowing
|
# expose internal debug module to every actor allowing for
|
||||||
# for use of ``await tractor.breakpoint()``
|
# use of ``await tractor.pause()``
|
||||||
enable_modules.append('tractor.devx._debug')
|
enable_modules.append('tractor.devx._debug')
|
||||||
|
|
||||||
# if debug mode get's enabled *at least* use that level of
|
# if debug mode get's enabled *at least* use that level of
|
||||||
|
@ -163,7 +169,20 @@ async def open_root_actor(
|
||||||
"Debug mode is only supported for the `trio` backend!"
|
"Debug mode is only supported for the `trio` backend!"
|
||||||
)
|
)
|
||||||
|
|
||||||
log.get_console_log(loglevel)
|
assert loglevel
|
||||||
|
_log = log.get_console_log(loglevel)
|
||||||
|
assert _log
|
||||||
|
|
||||||
|
# TODO: factor this into `.devx._stackscope`!!
|
||||||
|
if debug_mode:
|
||||||
|
try:
|
||||||
|
logger.info('Enabling `stackscope` traces on SIGUSR1')
|
||||||
|
from .devx import enable_stack_on_sig
|
||||||
|
enable_stack_on_sig()
|
||||||
|
except ImportError:
|
||||||
|
logger.warning(
|
||||||
|
'`stackscope` not installed for use in debug mode!'
|
||||||
|
)
|
||||||
|
|
||||||
# closed into below ping task-func
|
# closed into below ping task-func
|
||||||
ponged_addrs: list[tuple[str, int]] = []
|
ponged_addrs: list[tuple[str, int]] = []
|
||||||
|
|
Loading…
Reference in New Issue