Skip to content

Track Runtime run number #1074

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 9 commits into from
Nov 23, 2021
Prev Previous commit
Next Next commit
remove finalizer assert for raw pointer value; skip collection assert…
… on shutdown when loaded from Python
  • Loading branch information
lostmsu committed Nov 22, 2021
commit 6383a28b55e2b96f93cc4b4cd0b7ee466d67b75a
2 changes: 0 additions & 2 deletions src/runtime/pyobject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ internal PyObject(in StolenReference reference)
// when the managed wrapper is garbage-collected.
~PyObject()
{
Debug.Assert(obj != IntPtr.Zero || this.GetType() != typeof(PyObject));

if (obj != IntPtr.Zero)
{

Expand Down
10 changes: 7 additions & 3 deletions src/runtime/runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -379,14 +379,18 @@ internal static void Shutdown(ShutdownMode mode)
DisposeLazyModule(inspect);
PyObjectConversions.Reset();

bool everythingSeemsCollected = TryCollectingGarbage();
Debug.Assert(everythingSeemsCollected);
if (mode != ShutdownMode.Extension)
{
PyGC_Collect();
bool everythingSeemsCollected = TryCollectingGarbage();
Debug.Assert(everythingSeemsCollected);
}

Finalizer.Shutdown();
InternString.Shutdown();

if (mode != ShutdownMode.Normal && mode != ShutdownMode.Extension)
{
PyGC_Collect();
if (mode == ShutdownMode.Soft)
{
RuntimeState.Restore();
Expand Down