diff --git a/datasette/telemetry_testing.py b/datasette/telemetry_testing.py index 65a945b1..d9e953f1 100644 --- a/datasette/telemetry_testing.py +++ b/datasette/telemetry_testing.py @@ -385,6 +385,11 @@ def assert_package_never_imports_sdk(*module_names): rather than by grepping, so a lazy `import opentelemetry.sdk` inside a function body cannot slip past. A plugin should depend on `opentelemetry-api` only, exactly as Datasette core does. + + Run the test that calls this early in your suite: on macOS/CPython 3.13 + a process that has accumulated many threads can crash (SIGBUS) in + subprocess's fork+exec - Datasette's own conftest front-loads its + equivalent tests by name for exactly this reason. """ imports = "; ".join(f"import {name}" for name in module_names) code = ( diff --git a/tests/conftest.py b/tests/conftest.py index d3bbab1b..d886c5fe 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -185,6 +185,7 @@ def pytest_collection_modifyitems(config, items): # (SIGSEGV/SIGBUS inside _execute_child). Reproduces with any subprocess # call placed there, on an unmodified tree - running it first avoids it. move_to_front(items, "test_datasette_package_never_imports_the_sdk") + move_to_front(items, "test_kit_module_itself_never_imports_the_sdk") move_to_front(items, "test_no_provider_takes_the_fast_path") diff --git a/tests/test_telemetry_testing_kit.py b/tests/test_telemetry_testing_kit.py index cac55c19..d2123f7c 100644 --- a/tests/test_telemetry_testing_kit.py +++ b/tests/test_telemetry_testing_kit.py @@ -133,8 +133,16 @@ def test_linked_root_span_kwargs_with_no_current_span(otel_spans): def test_kit_module_itself_never_imports_the_sdk(): - # The kit imports the SDK lazily, so a plugin importing it at module - # level does not violate the api-only dependency rule. + """ + The kit imports the SDK lazily, so a plugin importing it at module + level does not violate the api-only dependency rule. + + conftest.py's pytest_collection_modifyitems() moves this test to the + front of the run by name - if you rename it, rename it there too. Like + every subprocess-spawning test in this suite, running it late crashes + the interpreter on macOS/CPython 3.13 (SIGBUS in fork+exec once the + process holds enough threads) - see the comment there. + """ assert_package_never_imports_sdk("datasette.telemetry_testing")