From 0614809d061001353000c4819145b4bf1c8dba26 Mon Sep 17 00:00:00 2001 From: Daniel Pinyol Date: Sun, 7 Jul 2024 22:59:08 +0200 Subject: [PATCH] call jl_atexit_hook when atexit (#516) Co-authored-by: Dani Pinyol --- pysrc/juliacall/__init__.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pysrc/juliacall/__init__.py b/pysrc/juliacall/__init__.py index 66bc34e5..6694298e 100644 --- a/pysrc/juliacall/__init__.py +++ b/pysrc/juliacall/__init__.py @@ -3,6 +3,8 @@ __version__ = '0.9.20' +import atexit + _newmodule = None def newmodule(name): @@ -199,6 +201,13 @@ def args_from_config(): None if sysimg is None else sysimg.encode('utf8'), ) + @atexit.register + def at_jl_exit(): + jl_atexit_hook = lib.jl_atexit_hook + jl_atexit_hook.argtypes = [c.c_int] + jl_atexit_hook.restype = None + jl_atexit_hook(0) + # initialise PythonCall jl_eval = lib.jl_eval_string jl_eval.argtypes = [c.c_char_p]