Skip to content

Commit f812ec7

Browse files
committed
Revert "handle ProcessExit event to avoid Python crash when CLR (in particular Mono) is unloaded before Python stops"
This reverts commit 39af4cb.
1 parent 651d145 commit f812ec7

File tree

2 files changed

+0
-11
lines changed

2 files changed

+0
-11
lines changed

src/runtime/pythonengine.cs

-7
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ public static void Initialize(IEnumerable<string> args, bool setSysArgv = true,
192192

193193
// Make sure we clean up properly on app domain unload.
194194
AppDomain.CurrentDomain.DomainUnload += OnDomainUnload;
195-
AppDomain.CurrentDomain.ProcessExit += OnProcessExit;
196195

197196
// The global scope gets used implicitly quite early on, remember
198197
// to clear it out when we shut down.
@@ -250,11 +249,6 @@ static void OnDomainUnload(object _, EventArgs __)
250249
Shutdown();
251250
}
252251

253-
static void OnProcessExit(object _, EventArgs __)
254-
{
255-
Shutdown();
256-
}
257-
258252
/// <summary>
259253
/// A helper to perform initialization from the context of an active
260254
/// CPython interpreter process - this bootstraps the managed runtime
@@ -325,7 +319,6 @@ public static void Shutdown(ShutdownMode mode)
325319
// If the shutdown handlers trigger a domain unload,
326320
// don't call shutdown again.
327321
AppDomain.CurrentDomain.DomainUnload -= OnDomainUnload;
328-
AppDomain.CurrentDomain.ProcessExit -= OnProcessExit;
329322

330323
PyScopeManager.Global.Clear();
331324
ExecuteShutdownHandlers();

src/runtime/runtime.cs

-4
Original file line numberDiff line numberDiff line change
@@ -393,10 +393,6 @@ internal static void Shutdown(ShutdownMode mode)
393393
{
394394
Py_Finalize();
395395
}
396-
else
397-
{
398-
PyGILState_Release(state);
399-
}
400396
}
401397
}
402398

0 commit comments

Comments
 (0)