Make SIGUSR1 `stackscope` dumps actually work
Two fixes to the hang-debug SIGUSR1 task-tree dump path, surfaced by `/code-review high` on #462, - re-add `_debug_mode` to the sub-actor handler-install gate in `_runtime.py`. Dropping it (rel. `3a386ba5`/`3d9c75b6` "Drop debug_mode gate", from the `custom_log_levels_api` follow-up) was meant to *also* enable non-pdb runs, but nothing sets `use_stackscope` from `debug_mode`, so debug-mode subs were left with NO handler — and the default SIGUSR1 disposition then *kills* them. Now additive: `_debug_mode OR use_stackscope OR env`. - pass `write_file=True` at both `dump_task_tree()` SIGUSR1 call sites so the advertised `/tmp/tractor-stackscope-<pid>` `.log` tee is actually written (was dead under `--capture=fd`). Matches `1b1ef10a` "Re-enable writing `stackscope` to file by default"; param from `0df90500`. (this patch was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-codetrionics_start_or_cancel
parent
f08a7d52b5
commit
d28173f4c0
|
|
@ -248,7 +248,7 @@ def _dump_then_relay(
|
||||||
|
|
||||||
'''
|
'''
|
||||||
try:
|
try:
|
||||||
dump_task_tree()
|
dump_task_tree(write_file=True)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
log.exception(
|
log.exception(
|
||||||
'`dump_task_tree()` raised (scheduled via '
|
'`dump_task_tree()` raised (scheduled via '
|
||||||
|
|
@ -314,7 +314,7 @@ def dump_tree_on_sig(
|
||||||
return
|
return
|
||||||
|
|
||||||
else:
|
else:
|
||||||
dump_task_tree()
|
dump_task_tree(write_file=True)
|
||||||
|
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
log.exception(
|
log.exception(
|
||||||
|
|
|
||||||
|
|
@ -930,20 +930,23 @@ class Actor:
|
||||||
# TODO! -[ ] another `Struct` for rtvs..
|
# TODO! -[ ] another `Struct` for rtvs..
|
||||||
rvs: dict[str, Any] = spawnspec._runtime_vars
|
rvs: dict[str, Any] = spawnspec._runtime_vars
|
||||||
|
|
||||||
# `stackscope` SIGUSR1 handler: install when EITHER
|
# `stackscope` SIGUSR1 handler: install when ANY of
|
||||||
# `use_stackscope` is set in rt-vars OR the
|
# `_debug_mode` / `use_stackscope` rt-vars OR the
|
||||||
# `TRACTOR_ENABLE_STACKSCOPE` env var is set (lighter
|
# `TRACTOR_ENABLE_STACKSCOPE` env var is set (the
|
||||||
# test-time hang-debug path; see
|
# latter being a lighter test-time hang-debug path;
|
||||||
# `tractor._testing.pytest`'s `--enable-stackscope`
|
# see `tractor._testing.pytest`'s `--enable-stackscope`
|
||||||
# CLI flag — env var propagates via fork-inherited
|
# CLI flag — env var propagates via fork-inherited
|
||||||
# environ).
|
# environ).
|
||||||
#
|
#
|
||||||
# NOTE, intentionally NOT gated on `_debug_mode` so
|
# NOTE, NOT *exclusively* gated on `_debug_mode` so
|
||||||
# SIGUSR1 task-tree dumps work in plain (non-pdb)
|
# SIGUSR1 task-tree dumps work in plain (non-pdb)
|
||||||
# runs too — esp. in infected-`asyncio` sub-actors
|
# runs too — but we DO still install under
|
||||||
# where the default SIGUSR1 action would otherwise
|
# `_debug_mode` since otherwise the default SIGUSR1
|
||||||
# terminate the proc.
|
# action would terminate the proc, esp. nasty in
|
||||||
|
# infected-`asyncio` sub-actors mid-REPL.
|
||||||
if (
|
if (
|
||||||
|
rvs.get('_debug_mode')
|
||||||
|
or
|
||||||
rvs.get('use_stackscope')
|
rvs.get('use_stackscope')
|
||||||
or
|
or
|
||||||
os.environ.get('TRACTOR_ENABLE_STACKSCOPE')
|
os.environ.get('TRACTOR_ENABLE_STACKSCOPE')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue