| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7e5ab52 commit 8075f48
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -111,6 +111,8 @@ public class Runtime | |||
| 111 | 111 | /// <summary> | |
| 112 | 112 | /// Initialize the runtime... | |
| 113 | 113 | /// </summary> | |
| 114 | + /// <remarks>When calling this method after a soft shutdown or a domain reload, | ||
| 115 | + /// this method acquires and releases the GIL. </remarks> | ||
| 114 | 116 | internal static void Initialize(bool initSigs = false, ShutdownMode mode = ShutdownMode.Default) | |
| 115 | 117 | { | |
| 116 | 118 | if (_isInitialized) | |
@@ -149,7 +151,8 @@ internal static void Initialize(bool initSigs = false, ShutdownMode mode = Shutd | |||
| 149 | 151 | } | |
| 150 | 152 | else | |
| 151 | 153 | { | |
| 152 | - PyEval_InitThreads(); | ||
| 154 | + // When initializing more than once (like on soft shutdown and domain | ||
| 155 | + // reload), the GIL might not be acquired by the current thread. | ||
| 153 | 156 | state = PyGILState_Ensure(); | |
| 154 | 157 | MainManagedThreadId = Thread.CurrentThread.ManagedThreadId; | |
| 155 | 158 | } | |
@@ -366,6 +369,8 @@ internal static void Shutdown(ShutdownMode mode) | |||
| 366 | 369 | // Some clr runtime didn't implement GC.WaitForFullGCComplete yet. | |
| 367 | 370 | } | |
| 368 | 371 | PyGILState_Release(state); | |
| 372 | + // Then release the GIL for good. | ||
| 373 | + PyEval_SaveThread(); | ||
| 369 | 374 | } | |
| 370 | 375 | else | |
| 371 | 376 | { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments