diff --git a/src/runtime/pythonengine.cs b/src/runtime/pythonengine.cs index c93443025..1338e2631 100644 --- a/src/runtime/pythonengine.cs +++ b/src/runtime/pythonengine.cs @@ -296,6 +296,7 @@ static void OnDomainUnload(object _, EventArgs __) static void OnProcessExit(object _, EventArgs __) { + Runtime.ProcessIsTerminating = true; Shutdown(); } diff --git a/src/runtime/runtime.cs b/src/runtime/runtime.cs index 1db86bc49..a2ee45e9c 100644 --- a/src/runtime/runtime.cs +++ b/src/runtime/runtime.cs @@ -92,6 +92,7 @@ internal static int GetRun() } internal static bool HostedInPython; + internal static bool ProcessIsTerminating; /// Initialize the runtime... /// @@ -254,7 +255,7 @@ internal static void Shutdown() var state = PyGILState_Ensure(); - if (!HostedInPython) + if (!HostedInPython && !ProcessIsTerminating) { // avoid saving dead objects TryCollectingGarbage(runs: 3);
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: