FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Removed `ShutdownMode`. Now always behaves like original `Reload` by lostmsu · Pull Request #1638 · pythonnet/pythonnet · GitHub

Removed ShutdownMode. Now always behaves like original Reload - #1638

Merged
lostmsu merged 4 commits into
pythonnet:masterfrom
losttech:cleanup/ShutdownModes
Dec 25, 2021
Merged

Removed ShutdownMode. Now always behaves like original Reload#1638
lostmsu merged 4 commits into
pythonnet:masterfrom
losttech:cleanup/ShutdownModes

Conversation

lostmsu commented Dec 20, 2021

Copy link
Copy Markdown
Member

What does this implement/fix? Explain your changes.

This removes all shutdown modes, except Reload (which you don't need to specify, because it is the only one left).

This means Python C runtime is never actually shut down when .NET calls PythonEngine.Shutdown(). Instead, anything from .NET exposed to Python before Shutdown becomes unavailable until PythonEngine.Initialize() is called again (which can be done from a different AppDomain).

Any other comments?

Also in this change:

  • dropped Python 3.6 support
  • fixed Python derived types not being decrefed when an instance is deallocated
  • reduced time and amount of storage needed for runtime reload
  • removed circular reference loop between Type <-> ConstructorBinding(s)
  • exposed Runtime.TryCollectingGarbage

A review from @amos402 would be welcome

lostmsu force-pushed the cleanup/ShutdownModes branch 3 times, most recently from 7ff467a to 7ab2bfc Compare December 20, 2021 21:11
Comment thread .github/workflows/main.yml Outdated
lostmsu force-pushed the cleanup/ShutdownModes branch from 7ab2bfc to fd451d5 Compare December 20, 2021 23:21

lostmsu commented Dec 20, 2021

Copy link
Copy Markdown
Member Author

@filmor looks like I got tests to pass, so this is ready.

lostmsu marked this pull request as ready for review December 20, 2021 23:39
lostmsu added this to the 3.0.0 milestone Dec 21, 2021
lostmsu force-pushed the cleanup/ShutdownModes branch 2 times, most recently from 3157cf5 to 5113257 Compare December 21, 2021 07:14
Comment thread src/runtime/pythonengine.cs Outdated
Comment thread src/runtime/pytype.cs Outdated
Comment thread src/runtime/runtime.cs
ResetPyMembers();
if (mode != ShutdownMode.Extension)
{
Py_Finalize();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This is my only real gripe with this: Embedders would not be able to finalise the Python runtime at all anymore. Maybe we should provide this (Shutdown() + Py_Finalize()) as a possible footgun with a long name?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

We can always add it if there is a strong request. Instead what happened is people opening bugs about crashes after restarting runtime because NumPy does not support it. I'd rather avoid it.

Moreover, the behavior of the whole thing when either of runtimes is shut down completely is pretty much undefined.

Comment thread src/runtime/runtime.cs Outdated
lostmsu force-pushed the cleanup/ShutdownModes branch 2 times, most recently from 8081238 to 8a093c2 Compare December 21, 2021 17:41
… is an equivalent of `ShutdownMode.Reload`

also in this change:
- fixed Python derived types not being decrefed when an instance is deallocated
- reduced time and amount of storage needed for runtime reload
- removed circular reference loop between Type <-> ConstructorBinding(s)
+ exposed Runtime.TryCollectingGarbage
clearing GCHandle from an instance of Python derived type would drop the last reference to it, so it was destroyed without being removed from reflectedObjects collection
lostmsu force-pushed the cleanup/ShutdownModes branch from 8a093c2 to dfb87dc Compare December 21, 2021 17:42
lostmsu requested a review from filmor December 23, 2021 18:41

lostmsu commented Dec 24, 2021

Copy link
Copy Markdown
Member Author

@filmor I am waiting for an explicit approval or more comments

lostmsu merged commit ec8b69f into pythonnet:master Dec 25, 2021
lostmsu deleted the cleanup/ShutdownModes branch December 25, 2021 18:22
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL