Skip to content

Commit 55eeaa9

Browse files
hjmjohnsonclaude
andcommitted
ENH: Add comprehensive GIL release safety tests
Add test_gil_release_safety.py covering 8 known SWIG -threads gotchas: 1. Callback safety (swig/swig#3091, swig/swig#2670) 2. Concurrent callbacks from 4 threads 3. Exception propagation across GIL boundary 4. Object destruction under concurrent access 5. Concurrent image processing (data races) 6. Signal handling while GIL is released 7. GIL reacquisition deadlock detection 8. Threading stress test (200 create/destroy cycles) Test results (15 assertions, 0 failures): ITK_PYTHON_RELEASE_GIL=ON: Python 3.10.20: 15 passed, 0 failed, 0 skipped Python 3.11.15: 15 passed, 0 failed, 0 skipped Python 3.12.13: 15 passed, 0 failed, 0 skipped Python 3.13.12: 15 passed, 0 failed, 0 skipped Python 3.14.3: 15 passed, 0 failed, 0 skipped ITK_PYTHON_RELEASE_GIL=OFF: Python 3.13.12: 15 passed, 0 failed, 0 skipped All tests pass regardless of the GIL release setting because they test safety invariants (no crashes, no deadlocks, no data corruption) rather than concurrency speedup (which is tested by the existing test_gil_release.py). Each test includes references to the SWIG issue or Python doc that motivated it. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1e73a2b commit 55eeaa9

2 files changed

Lines changed: 497 additions & 0 deletions

File tree

Wrapping/Generators/Python/Tests/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,3 +268,11 @@ itk_python_add_test(
268268
COMMAND
269269
${CMAKE_CURRENT_SOURCE_DIR}/test_gil_release.py
270270
)
271+
272+
# Comprehensive GIL release safety tests: callbacks, exceptions,
273+
# concurrency, deadlock, signals, stress
274+
itk_python_add_test(
275+
NAME PythonGILReleaseSafetyTest
276+
COMMAND
277+
${CMAKE_CURRENT_SOURCE_DIR}/test_gil_release_safety.py
278+
)

0 commit comments

Comments
 (0)