If an exception is raised in any of the python module functions
invoked by mgr (for example, ImportError if rest_framework isn't
available when serve() in called in the rest module), print the
module name along with the failed method name.
This commit also fixes what looks to me like a missed call to
PyGILState_Release() in the failure case in MgrPyModule::serve().
Signed-off-by: Tim Serong <tserong@suse.com>
auto pValue = PyObject_CallMethod(pClassInstance,
const_cast<char*>("serve"), nullptr);
+ int r = 0;
if (pValue != NULL) {
Py_DECREF(pValue);
} else {
+ derr << "Failed to invoke serve() on " << module_name << dendl;
PyErr_Print();
- return -EINVAL;
+ r = -EINVAL;
}
PyGILState_Release(gstate);
- return 0;
+ return r;
}
// FIXME: DRY wrt serve
if (pValue != NULL) {
Py_DECREF(pValue);
} else {
- PyErr_Print();
derr << "Failed to invoke shutdown() on " << module_name << dendl;
+ PyErr_Print();
}
PyGILState_Release(gstate);
if (pValue != NULL) {
Py_DECREF(pValue);
} else {
+ derr << "Failed to invoke notify() on " << module_name << dendl;
PyErr_Print();
// FIXME: callers can't be expected to handle a python module
// that has spontaneously broken, but Mgr() should provide
Py_DECREF(pResult);
} else {
+ derr << "Failed to invoke handle_command() on " << module_name << dendl;
PyErr_Print();
r = -EINVAL;
}