Split from PR 958: restoring the __import__ after shutdown.#993
Merged
filmor merged 1 commit intopythonnet:masterfrom Nov 21, 2019
Merged
Split from PR 958: restoring the __import__ after shutdown.#993filmor merged 1 commit intopythonnet:masterfrom
filmor merged 1 commit intopythonnet:masterfrom
Conversation
When C# shuts down we should restore Python to its original state.
Codecov Report
@@ Coverage Diff @@
## master #993 +/- ##
=======================================
Coverage 86.71% 86.71%
=======================================
Files 1 1
Lines 301 301
=======================================
Hits 261 261
Misses 40 40
Continue to review full report at Codecov.
|
Member
|
Nice, thank you very much :) |
AlexCatarino
pushed a commit
to QuantConnect/pythonnet
that referenced
this pull request
Jun 27, 2020
…t#993) When C# shuts down we should restore Python to its original state.
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.
When C# shuts down we should restore Python to its original state.
What does this implement/fix? Explain your changes.
This is adapted from the large patch that amos put in PR #958. It restores the import hook.
Does this close any currently open issues?
Not yet.
Any other comments?
I would have used the ShutdownHandler but that's only in the PythonEngine, whereas
__import__is in the Runtime. Maybe we should move the ShutdownHandler mechanism to the runtime?Checklist
Check all those that are applicable and complete.
Can't really test this at the moment. After Py_Finalize (in Shutdown), we can't check the state of the
__import__function until we call Py_Initialize. But Py_Initialize will create a new__import__, so we can't see whether our code ran. This change only becomes relevant when we stop calling Py_Finalize in Shutdown.AUTHORSCHANGELOG