Repository navigation
ENH: Release Python GIL during ITK operations - #5776
Conversation
e121d68 to
df497d8
Compare
|
@copilot apply my review suggestions. |
Applied all review suggestions in commit bae360f:
|
dzenanz
left a comment
There was a problem hiding this comment.
Looks good, but does it work? Can someone test this locally?
|
I tested it locally, tests pass, including the new test, and I tested the example in the Migration Guide, and it works. It will be interesting to see how this behaves in the wild with dask, etc. after released. |
bae360f to
910410a
Compare
910410a to
47fd5b0
Compare
347e10a to
c37ebca
Compare
|
I now see that Matt doesn't have write access? Why? He is a member of ITKLeadDevelopers team, and that team has admin access in ITK repo: |
- Added cmake option ITK_PYTHON_RELEASE_GIL (default ON) in WrappingOptions.cmake - Modified Python CMakeLists.txt to add -threads flag to SWIG when option is enabled - Created test_gil_release.py to verify GIL is released during ITK operations - Added test to CMakeLists.txt Co-authored-by: Matthew McCormick <matt@fideus.io> Co-authored-by: dzenanz <1792121+dzenanz@users.noreply.github.com>
Co-authored-by: Matthew McCormick <matt@fideus.io>
c37ebca to
f8b120f
Compare
|
@thewtex I think this is ready for testing in the main branch. If you are satisfied with the current codebase, would you please merge? I rebased and fixed merge conflicts, so I would prefer you to do the final merge. |
|
@dzenanz I have not lost merge permissions, but thanks for checking :-). @hjmjohnson yes, it LGTM. Let's put it out there for testing in the wild. |
|
@thewtex your PR approval had gray check mark, instead of the usual green. |
…eConsortium/copilot/release-gil-itk-operations ENH: Release Python GIL during ITK operations
…eConsortium/copilot/release-gil-itk-operations ENH: Release Python GIL during ITK operations

Description
ITK Python wrappers hold the Global Interpreter Lock during C++ operations, preventing concurrent execution in multi-threaded contexts (Dask, Ray,
threadingmodule) and causing server lockups.Changes
ITK_PYTHON_RELEASE_GIL(defaultON) to control GIL release behavior-threadsflag to generate wrappers that release/reacquire GIL around C++ callstest_gil_release.pyverifies concurrent execution via timing overlap detection with 4 Python threads and single-threaded ITK filters for reliable testingImplementation
Follows SimpleITK's approach (commit e9ce7283) - SWIG's
-threadsflag handles GIL release/reacquire automatically.Disable with
-DITK_PYTHON_RELEASE_GIL=OFFif callbacks/events require GIL.Test Configuration
The GIL release test is designed for reliability and sensitivity:
PR Checklist
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.