8000 allow leaking PyObject instances when CLR is stared from Python · pythonnet/pythonnet@fe1b26a · GitHub
[go: up one dir, main page]

Skip to content

Commit fe1b26a

Browse files
committed
allow leaking PyObject instances when CLR is stared from Python
1 parent 507a2bf commit fe1b26a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/runtime/pythonengine.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ public static IntPtr InitExt()
317317
{
318318
Initialize(setSysArgv: false, mode: ShutdownMode.Extension);
319319

320+
Finalizer.Instance.ErrorHandler += AllowLeaksDuringShutdown;
321+
320322
// Trickery - when the import hook is installed into an already
321323
// running Python, the standard import machinery is still in
322324
// control for the duration of the import that caused bootstrap.
@@ -358,6 +360,14 @@ public static IntPtr InitExt()
358360
.DangerousMoveToPointerOrNull();
359361
}
360362

363+
private static void AllowLeaksDuringShutdown(object sender, Finalizer.ErrorArgs e)
364+
{
365+
if (e.Error is RuntimeShutdownException)
366+
{
367+
e.Handled = true;
368+
}
369+
}
370+
361371
/// <summary>
362372
/// Shutdown Method
363373
/// </summary>

0 commit comments

Comments
 (0)
0