Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Split from PR 958: restoring the __import__ after shutdown. #993

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 21, 2019

Conversation

benoithudson
Copy link
Contributor

@benoithudson benoithudson commented Nov 21, 2019

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.

  • Make sure to include one or more tests for your change

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.

  • If an enhancement PR, please create docs and at best an example
  • Add yourself to AUTHORS
  • Updated the CHANGELOG

When C# shuts down we should restore Python to its original state.
@codecov-io
Copy link

codecov-io commented Nov 21, 2019

Codecov Report

Merging #993 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #993   +/-   ##
=======================================
  Coverage   86.71%   86.71%           
=======================================
  Files           1        1           
  Lines         301      301           
=======================================
  Hits          261      261           
  Misses         40       40
Flag Coverage Δ
#setup_linux 65.44% <ø> (ø) ⬆️
#setup_windows 71.42% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2736094...668c590. Read the comment docs.

@filmor filmor merged commit 5f2e2e2 into pythonnet:master Nov 21, 2019
@filmor
Copy link
Member

filmor commented Nov 21, 2019

Nice, thank you very much :)

@benoithudson benoithudson deleted the 958-import-hook branch November 21, 2019 15:41
@benoithudson benoithudson mentioned this pull request Nov 21, 2019
4 tasks
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants