diff --git a/crates/clawhdf5-py/tests/test_edit.py b/crates/clawhdf5-py/tests/test_edit.py index c0b7ba6..ac28607 100644 --- a/crates/clawhdf5-py/tests/test_edit.py +++ b/crates/clawhdf5-py/tests/test_edit.py @@ -896,3 +896,38 @@ def test_path_replaced_between_edits(h5py, tmp_path): from pathlib import Path _held_file_edited(h5py, moved, Path(path), other_bytes) + +def test_an_edit_releases_the_gil(h5py, tmp_path): + """Another Python thread keeps running while a large edit is written: + had the edit held the GIL, the other thread would stall for the whole + edit (Rust code never yields it).""" + import time + path = str(tmp_path / "big.h5") + with h5py.File(path, "w") as f: + f.create_dataset("d", shape=(1024, 1024), dtype=" 0.1, "the edit is too quick to tell" + assert gaps.max() < 0.5 * (t1 - t0), ( + f"the other thread stalled for {gaps.max():.3f} s of a {t1 - t0:.3f} s edit")