From 208e7c09268d83671b7613b72d9c2f8eb672f33b Mon Sep 17 00:00:00 2001 From: goodboy Date: Wed, 29 Apr 2026 17:29:38 -0400 Subject: [PATCH] Honor `TRACTOR_LOGLEVEL`+`TRACTOR_SPAWN_METHOD` env-vars Add env-var overrides inside `._root.open_root_actor()` so devs/test-runs can swap the actor-spawn backend or crank console verbosity *without* touching application code. In `._root.open_root_actor()`, - read `TRACTOR_LOGLEVEL` early, overriding any caller-passed `loglevel` and stashing an `env_ll_report` to emit once the console log is set up. - pull the `loglevel` fallback (`or _default_loglevel`) and `log.get_console_log()` init *up* so the env-var report routes through tractor's own logger. - read `TRACTOR_SPAWN_METHOD`, overriding any caller-passed `start_method` and warn-logging when the env-var clobbers an explicit caller value. Wire the same vars through `tests/devx/conftest.py::spawn`, - request the `loglevel` fixture, set both `TRACTOR_LOGLEVEL` and `TRACTOR_SPAWN_METHOD` in `os.environ` before each `pexpect.spawn()` (inherited by the example subproc). - expand `supported_spawners` to include `main_thread_forkserver` and `subint_forkserver` bc example scripts no longer need per-script CLI plumbing. - pop both vars in fixture teardown so a leaked value can't re-route a later in-process tractor test's spawn-backend or loglevel. (this patch was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code --- tests/devx/conftest.py | 50 ++++++++++++++++++++++--- tractor/_root.py | 83 +++++++++++++++++++++++++++++++++++------- 2 files changed, 115 insertions(+), 18 deletions(-) diff --git a/tests/devx/conftest.py b/tests/devx/conftest.py index f7d336eb..c62dc4a1 100644 --- a/tests/devx/conftest.py +++ b/tests/devx/conftest.py @@ -56,6 +56,7 @@ type PexpectSpawner = Callable[ @pytest.fixture def spawn( start_method: str, + loglevel: str, testdir: pytest.Pytester, reg_addr: tuple[str, int], @@ -67,11 +68,12 @@ def spawn( ''' supported_spawners: set[str] = { 'trio', - # ?TODO, other spawners that will work? - # - [ ] need to pass `start_method={spawner}` to underlying - # `examples/debugging/