Reworked ManagedType to not keep python references to self#2
Merged
lostmsu merged 45 commits intoprecise-API-referencesfrom Dec 9, 2021
Merged
Reworked ManagedType to not keep python references to self#2lostmsu merged 45 commits intoprecise-API-referencesfrom
ManagedType to not keep python references to self#2lostmsu merged 45 commits intoprecise-API-referencesfrom
Conversation
978fd25 to
78fc99d
Compare
…beMethodBase contains no method
they are no longer needed as ClassBase instances no longer hold Python references to themselves
78fc99d to
78a18ba
Compare
78a18ba to
1a4ada7
Compare
…ype instances, unless they are per-alloc call no problem though - they will be collected by .NET garbage collector eventually
…cted directly instead. Also fixes event_rename domain reload test case
it should not be possible to construct an instance of a class that has been unloaded
04b5d9e to
fd36721
Compare
fd36721 to
cb58147
Compare
removed debug code, that ensured Python GC list integrity
69be9b2 to
a8ef06c
Compare
… to allow them to be garbage collected
…ht shut down and unload corresponding methods before Python terminates
Author
|
@filmor this seems to be working (at least tests are passing). The diff starts on top of pythonnet#1603 I wish it were smaller, but the old code that supported app domains for 3.8 and below just does not work for 3.9 and 3.10 (it made assumptions about internal GC data structures, that are no longer valid). |
fad8f0b to
d6edace
Compare
lostmsu
commented
Nov 25, 2021
| namespace Python.Runtime; | ||
|
|
||
| [Serializable] | ||
| internal class EventHandlerCollection: Dictionary<object, List<Handler>> |
Author
There was a problem hiding this comment.
mostly moved from eventobject.cs
remote analyzer workaround
filmor
reviewed
Dec 9, 2021
| } | ||
|
|
||
| private static void ResotreModules(IntPtr dummyGC) | ||
| private static void ResotreModules() |
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.
Remove
pyHandleandtpHandlefields inManagedTypewhich used to make instances ofManagedTypeself-referential.ManagedTypenow providesAlloc, that creates a Python wrapper around the instance and returns a strong reference to it. That reference is explicitly passed around everywherepyHandlewas needed (usually asBorrowedReference ob).With reference loops gone (one notable exception is
PythonDerivedTypethat still requires it for .NET to be able to access Python implementation and vice versa), reference tracking is simplified. Lists of all wrapped .NET objects is stored inCLRObject.reflectedObjectsand all extension types inExtensionType.loadedExtensionsfor cross-domain support replacing "track types".PyObjectdisposal and finalization andPythonDerivedTypefinalization have been reworked to permit them when and only when both Python runtime and Python.NET engine are in appropriate states.A few minor bugs were fixed.