Skip to content

Commit e0c9152

Browse files
Merge pull request ceph#62197 from NitzanMordhai/wip-nitzan-mgr-pymodule-mem-leaks
mgr: PyModule memory leaks fix
2 parents 076eb17 + 3366ef5 commit e0c9152

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/mgr/PyModule.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,7 @@ int PyModule::load_subclass_of(const char* base_class, PyObject** py_class)
667667
error_string = peek_pyerror();
668668
derr << "Module not found: '" << module_name << "'" << dendl;
669669
derr << handle_pyerror(true, module_name, "PyModule::load_subclass_of") << dendl;
670+
Py_DECREF(mgr_module_type);
670671
return -ENOENT;
671672
}
672673
auto locals = PyModule_GetDict(plugin_module);
@@ -707,6 +708,8 @@ PyModule::~PyModule()
707708
Gil gil(pMyThreadState, true);
708709
Py_XDECREF(pClass);
709710
Py_XDECREF(pStandbyClass);
711+
Py_EndInterpreter(pMyThreadState.ts);
712+
pMyThreadState.ts = nullptr;
710713
}
711714
}
712715

0 commit comments

Comments
 (0)