Commit 55eeaa9
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
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
0 commit comments