8000 Track Runtime run number by lostmsu · Pull Request #1074 · pythonnet/pythonnet · GitHub
[go: up one dir, main page]

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
Merged
Prev Previous commit
Next Next commit
allow leaking PyObject instances when CLR is stared from Python
  • Loading branch information
lostmsu committed Nov 12, 2021
commit 9e815a62ebcc52c5c958db4b63e4ca987b8c5f38
10 changes: 10 additions & 0 deletions src/runtime/pythonengine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ public static IntPtr InitExt()
{
Initialize(setSysArgv: false, mode: ShutdownMode.Extension);

Finalizer.Instance.ErrorHandler += AllowLeaksDuringShutdown;

// Trickery - when the import hook is installed into an already
// running Python, the standard import machinery is still in
// control for the duration of the import that caused bootstrap.
Expand Down Expand Up @@ -358,6 +360,14 @@ public static IntPtr InitExt()
.DangerousMoveToPointerOrNull();
}

private static void AllowLeaksDuringShutdown(object sender, Finalizer.ErrorArgs e)
{
if (e.Error is RuntimeShutdownException)
{
e.Handled = true;
}
}

/// <summary>
/// Shutdown Method
/// </summary>
Expand Down
0