Skip to content

Commit ab388ac

Browse files
committed
bump
1 parent 7c5e6f1 commit ab388ac

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

py/src/braintrust/test_context.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
5356
os.environ["BRAINTRUST_APP_URL"] = "https://www.braintrust.dev"
@@ -58,9 +61,11 @@ def _threadpool_scenario(test_logger, with_memory_logger):
5861
os.environ.setdefault("GOOGLE_API_KEY", os.environ.get("GEMINI_API_KEY", "your_google_api_key_here"))
5962
from braintrust import logger as _logger
6063
from braintrust.test_helpers import init_test_logger
64+
from braintrust.util import LazyValue
6165
from braintrust.test_context import {fn_name} as _fn
6266
_logger._state.reset_parent_state()
6367
with _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

Comments
 (0)