mirror of
https://github.com/simonw/datasette.git
synced 2026-09-09 01:54:15 +02:00
Front-load the kit's subprocess test to dodge the macOS fork crash
test_kit_module_itself_never_imports_the_sdk shells out, and like every subprocess-spawning test in this suite it crashes the interpreter with SIGBUS on macOS/CPython 3.13 when it runs late enough that the process holds many threads - the exact failure conftest already front-loads test_datasette_package_never_imports_the_sdk for. Move it to the front too, and note the hazard in assert_package_never_imports_sdk's docstring since plugin suites will call it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012U7coQfVu8nK2R4q2mCULA
This commit is contained in:
parent
2a05263ab8
commit
a14ad47d0c
3 changed files with 16 additions and 2 deletions
|
|
@ -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 = (
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue