@@ -48,6 +48,9 @@ def _threadpool_scenario(test_logger, with_memory_logger):
4848# ThreadPoolExecutor.submit globally. Without this flag the background
4949# logger's atexit handler tries to flush via the patched executor during
5050# Python shutdown, which crashes the subprocess (SIGABRT / 0xC0000409).
51+ # The memory logger override is thread-local, so worker threads also need a
52+ # process-local fallback to avoid the real HTTP background logger in this
53+ # isolated test process.
5154_SCENARIO_TEMPLATE = """\
5255 import os, inspect, asyncio
5356os.environ["BRAINTRUST_APP_URL"] = "https://www.braintrust.dev"
@@ -58,9 +61,11 @@ def _threadpool_scenario(test_logger, with_memory_logger):
5861os.environ.setdefault("GOOGLE_API_KEY", os.environ.get("GEMINI_API_KEY", "your_google_api_key_here"))
5962from braintrust import logger as _logger
6063from braintrust.test_helpers import init_test_logger
64+ from braintrust.util import LazyValue
6165from braintrust.test_context import {fn_name} as _fn
6266_logger._state.reset_parent_state()
6367with _logger._internal_with_memory_background_logger() as _bgl:
68+ _logger._state._global_bg_logger = LazyValue(lambda: _bgl, use_mutex=False)
6469 _tl = init_test_logger("test-context-project")
6570 if {instrument}:
6671 from braintrust.wrappers.threads import setup_threads
0 commit comments