Conversation
Collaborator
Author
|
@esheldon this one is ready for review! |
esheldon
approved these changes
Dec 9, 2025
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.
This PR enables python free-threading builds and add tests for them.
The changes here mean that the package won't reenable the GIL when imported.
However, there are some important limitations that are fundamental:
cfitsiodoes not support more than one thread using a given file pointer. Thusfitsiowon't have support either. As usual with file-related potential race conditions, we leave this to the user to manage.Even in free-threaded python, a you have to call the functions that detach the thread state in order to get performance gains for blocking i/o operations, etc. See this bit in the python manual (https://docs.python.org/3/c-api/init.html#thread-state-and-the-global-interpreter-lock)
So confusingly, we still need to "release the GIL" per feat: release the GIL very minimally #476 even in a free-threaded build. For this PR, I am punting on this task to a future PRs.
Edit: The code snippet below does not work. I have another solution in another PR, but we can punt for now.
We could use the ideas here to raise errors on concurrent use of FITS objects from more than one thread. I will leave this to a potential future PR if we think it is worth the complexity.