Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Ensure that shutdown is called from Python
  • Loading branch information
filmor committed Mar 10, 2022
commit 39db9f4d4d9e3e7d8d3e687b3ed74cb3d8f3ddb8
6 changes: 3 additions & 3 deletions pythonnet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ def load():
set_default_runtime()

dll_path = join(dirname(__file__), "runtime", "Python.Runtime.dll")

_LOADER_ASSEMBLY = _RUNTIME.get_assembly(dll_path)

func = _LOADER_ASSEMBLY["Python.Runtime.Loader.Initialize"]
if func(''.encode("utf8")) != 0:
if func(b"") != 0:
raise RuntimeError("Failed to initialize Python.Runtime.dll")

import atexit
Expand All @@ -51,7 +51,7 @@ def unload():
global _RUNTIME
if _LOADER_ASSEMBLY is not None:
func = _LOADER_ASSEMBLY["Python.Runtime.Loader.Shutdown"]
if func(b"") != 0:
if func(b"full_shutdown") != 0:
raise RuntimeError("Failed to call Python.NET shutdown")

if _RUNTIME is not None:
Expand Down