Repository navigation
Conversation
The global SWIG nothreadallow feature overrides threading support. Limit GIL release to pipeline updates and reacquire it for callbacks. Replace setup-time overlap detection with a native execution check. Fixes InsightSoftwareConsortium#7000
sdiebolt
marked this pull request as ready for review
October 24, 2026 00:51
Contributor
[High impact] The change affects pipeline updates across ITK’s Python wrappers. Fix the unchecked float requirement in Findings
|
Custom wrapping builds may disable float while retaining other scalar types. Exercise an available two-dimensional specialization instead.
Author
|
The Linux failure looks separate from this fix: filtering succeeds, then the median test’s type-hint check raises All three GIL-related tests passed in that job. The float-wrapping review finding is fixed in 2d8272e; those tests also pass locally. |
7 tasks done
Observers can execute while pipeline updates have released the GIL. Protect callable validation as well as invocation and error handling.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Let Python threads run during ITK pipeline updates, and make the regression test check filtering rather than setup. Closes #7000.
Why the GIL stayed locked
The 2019 GIL-release change enabled SWIG threading but also set
nothreadallow, citing this SWIG discussion. That advice served a different goal: protecting director callbacks while deliberately avoiding GIL release around native calls. The combination therefore did not provide the concurrency described by the commit.The later
-threadsaddition in #5776/#6022 left that override in place. Its regression test accepted overlapping setup/filtering intervals as evidence of GIL release. Measured intervals were about 0.81 seconds, but only 0.002–0.003 seconds were insideUpdate().What this fixes
Update()andUpdateLargestPossibleRegion(), retaining it for unrelated wrappers and respectingITK_PYTHON_RELEASE_GIL.PyImageFiltercallbacks and beforePyCommandvalidates observer callables.Update()exceptions instead of errors that could arise in Python-side file-reading setup.Validation
Linux x86_64, CPython 3.13.9, NumPy 2.3.4, Release build:
Update()appears to hold the GIL despite GIL-release support #7000's ticker workload: 913–927 ticks during 0.97–0.98 seconds of filtering.PyCallable_Check()without the GIL before thePyCommandfix; the probe and full safety script pass after it.The initial Linux CI run also passed all three targeted tests. Its separate median type-hint failure is described in the PR comments.
Full local suite, Python 3.14 wheel, and full GIL-disabled native build validation were not run. CI must validate the latest revision.
PR Checklist
AI assistance
AI assistance supported diagnosis, implementation, and local testing.