test(py): detect a held GIL, and errors h5py does not raise

test_threads_read_the_same_file passed with the GIL held. The new
test_reads_release_the_gil measures the longest stall of a spinning
Python thread while another reads: with py.detach removed from the read
it stalled 0.062 s of a 0.064 s read and failed; with it, about 3 ms.
test_errors_match_h5py now compares the result whenever h5py reads the
key, instead of only checking that we raise when h5py raises, over a
longer key list.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
osobh
2026-09-26 09:03:53 -05:00
co-authored by Claude Opus 5.5
parent 05b0192a60
commit 17edfe2cf0
2 changed files with 65 additions and 5 deletions
+8
View File
@@ -94,6 +94,14 @@
- **`ds[np.array(1)]` is an integer index**, as in h5py; a 0-d integer
array went down the index-list path and raised a confusing `TypeError`.
The h5py comparison keys now include 0-d arrays on every axis.
- **Tests that would notice a held GIL, and our extra errors.**
`test_reads_release_the_gil` times a Python thread spinning while another
reads: with the read made to hold the GIL it stalls for the whole read
(0.062 s of a 0.064 s read) and the test fails; released, its longest
stall is about 3 ms. (The existing threads test only checked values.)
`test_errors_match_h5py` now also requires that every key h5py reads
reads here too, with the same result, and covers more keys (0-d arrays,
repeated and empty lists, `()`, `...`).
- **CI builds and tests the Python package.** It was excluded from CI.
`scripts/ci-test.sh` now lints `clawhdf5-py`, builds the wheel with
maturin, unpacks it under `target/` and runs the pytest suite; skipped