fix: hold gil before calling tree_cache().clear()

This commit is contained in:
Paul Zhu
2025-07-28 22:32:32 -07:00
parent 970dbe8e25
commit 63f5240b64

View File

@@ -1503,6 +1503,8 @@ void init_transforms(nb::module_& m) {
// Register static Python object cleanup before the interpreter exits // Register static Python object cleanup before the interpreter exits
auto atexit = nb::module_::import_("atexit"); auto atexit = nb::module_::import_("atexit");
atexit.attr("register")(nb::cpp_function([]() { atexit.attr("register")(nb::cpp_function([]() {
nb::gil_scoped_acquire gil;
tree_cache().clear(); tree_cache().clear();
mx::detail::compile_clear_cache(); mx::detail::compile_clear_cache();
})); }));