| 98 | } |
| 99 | |
| 100 | int StandbyPyModule::load() |
| 101 | { |
| 102 | Gil gil(py_module->pMyThreadState, true); |
| 103 | |
| 104 | // We tell the module how we name it, so that it can be consistent |
| 105 | // with us in logging etc. |
| 106 | auto pThisPtr = PyCapsule_New(this, nullptr, nullptr); |
| 107 | ceph_assert(pThisPtr != nullptr); |
| 108 | auto pModuleName = PyUnicode_FromString(get_name().c_str()); |
| 109 | ceph_assert(pModuleName != nullptr); |
| 110 | auto pArgs = PyTuple_Pack(2, pModuleName, pThisPtr); |
| 111 | Py_DECREF(pThisPtr); |
| 112 | Py_DECREF(pModuleName); |
| 113 | |
| 114 | pClassInstance = PyObject_CallObject(py_module->pStandbyClass, pArgs); |
| 115 | Py_DECREF(pArgs); |
| 116 | if (pClassInstance == nullptr) { |
| 117 | derr << "Failed to construct class in '" << get_name() << "'" << dendl; |
| 118 | derr << handle_pyerror(true, get_name(), "StandbyPyModule::load") << dendl; |
| 119 | return -EINVAL; |
| 120 | } else { |
| 121 | dout(1) << "Constructed class from module: " << get_name() << dendl; |
| 122 | return 0; |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | bool StandbyPyModule::get_config(const std::string &key, |
| 127 | std::string *value) const |
no test coverage detected