Grab the GIL on shutdown when checking for exceptions#1832
Closed
BadSingleton wants to merge 1 commit intopythonnet:masterfrom
Closed
Grab the GIL on shutdown when checking for exceptions#1832BadSingleton wants to merge 1 commit intopythonnet:masterfrom
BadSingleton wants to merge 1 commit intopythonnet:masterfrom
Conversation
The GIL isn't taken when being called from the DomainUnload handler.
lostmsu
requested changes
Jun 23, 2022
Comment on lines
+361
to
+366
| var pyGILState = PyGILState.PyGILState_UNLOCKED; | ||
| if (!Runtime.HostedInPython) | ||
| { | ||
| pyGILState = Runtime.PyGILState_Ensure(); | ||
| } | ||
|
|
Member
There was a problem hiding this comment.
Since Py.GIL() no longer tries to force runtime initialization, I think the code would be easier to read with a simple using (Py.GIL()) { ... } around the if.
I don't think it is necessary to check if we are hosted in Python. Runtime.Shutdown further down does not.
Member
There was a problem hiding this comment.
Another issue is that the code below throws when Python error is set. And that throw prevents the GIL release code to be reached making the GIL unreleasable. Would not be a problem with using Py.GIL
Member
There was a problem hiding this comment.
I'll adjust it accordingly s.t. we can tag rc1.
5 tasks
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.
What does this implement/fix? Explain your changes.
The GIL isn't taken when being called from the DomainUnload handler. Take it to avoid a crash when calling
Exceptions.ErrorOccurred()Does this close any currently open issues?
#1831
Checklist
Check all those that are applicable and complete.
AUTHORS