| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ce8ee90 commit 4c4bcb0
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -189,9 +189,6 @@ public static void Initialize(IEnumerable<string> args, bool setSysArgv = true, | |||
| 189 | 189 | // Make sure we clean up properly on app domain unload. | |
| 190 | 190 | AppDomain.CurrentDomain.DomainUnload += OnDomainUnload; | |
| 191 | 191 | ||
| 192 | - // Remember to shut down the runtime. | ||
| 193 | - AddShutdownHandler(Runtime.Shutdown); | ||
| 194 | - | ||
| 195 | 192 | // The global scope gets used implicitly quite early on, remember | |
| 196 | 193 | // to clear it out when we shut down. | |
| 197 | 194 | AddShutdownHandler(PyScopeManager.Global.Clear); | |
@@ -318,7 +315,8 @@ public static IntPtr InitExt() | |||
| 318 | 315 | /// Python runtime can no longer be used in the current process | |
| 319 | 316 | /// after calling the Shutdown method. | |
| 320 | 317 | /// </remarks> | |
| 321 | - public static void Shutdown() | ||
| 318 | + /// <param name="mode">The ShutdownMode to use when shutting down the Runtime</param> | ||
| 319 | + public static void Shutdown(ShutdownMode mode) | ||
| 322 | 320 | { | |
| 323 | 321 | if (!initialized) | |
| 324 | 322 | { | |
@@ -330,11 +328,26 @@ public static void Shutdown() | |||
| 330 | 328 | ||
| 331 | 329 | PyScopeManager.Global.Clear(); | |
| 332 | 330 | ExecuteShutdownHandlers(); | |
| 331 | + // Remember to shut down the runtime. | ||
| 332 | + Runtime.Shutdown(mode); | ||
| 333 | 333 | PyObjectConversions.Reset(); | |
| 334 | 334 | ||
| 335 | 335 | initialized = false; | |
| 336 | 336 | } | |
| 337 | 337 | ||
| 338 | + /// <summary> | ||
| 339 | + /// Shutdown Method | ||
| 340 | + /// </summary> | ||
| 341 | + /// <remarks> | ||
| 342 | + /// Shutdown and release resources held by the Python runtime. The | ||
| 343 | + /// Python runtime can no longer be used in the current process | ||
| 344 | + /// after calling the Shutdown method. | ||
| 345 | + /// </remarks> | ||
| 346 | + public static void Shutdown() | ||
| 347 | + { | ||
| 348 | + Shutdown(Runtime.ShutdownMode); | ||
| 349 | + } | ||
| 350 | + | ||
| 338 | 351 | /// <summary> | |
| 339 | 352 | /// Called when the engine is shut down. | |
| 340 | 353 | /// | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -312,7 +312,7 @@ private static IntPtr Get_PyObject_NextNotImplemented() | |||
| 312 | 312 | return iternext; | |
| 313 | 313 | } | |
| 314 | 314 | ||
| 315 | - internal static void Shutdown() | ||
| 315 | + internal static void Shutdown(ShutdownMode mode) | ||
| 316 | 316 | { | |
| 317 | 317 | if (Py_IsInitialized() == 0 || !_isInitialized) | |
| 318 | 318 | { | |
@@ -322,7 +322,6 @@ internal static void Shutdown() | |||
| 322 | 322 | ||
| 323 | 323 | var state = PyGILState_Ensure(); | |
| 324 | 324 | ||
| 325 | - var mode = ShutdownMode; | ||
| 326 | 325 | if (mode == ShutdownMode.Soft) | |
| 327 | 326 | { | |
| 328 | 327 | RunExitFuncs(); | |
@@ -375,6 +374,12 @@ internal static void Shutdown() | |||
| 375 | 374 | } | |
| 376 | 375 | } | |
| 377 | 376 | ||
| 377 | + internal static void Shutdown() | ||
| 378 | + { | ||
| 379 | + var mode = ShutdownMode; | ||
| 380 | + Shutdown(mode); | ||
| 381 | + } | ||
| 382 | + | ||
| 378 | 383 | internal static ShutdownMode GetDefaultShutdownMode() | |
| 379 | 384 | { | |
| 380 | 385 | string modeEvn = Environment.GetEnvironmentVariable("PYTHONNET_SHUTDOWN_MODE"); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments