MCPcopy Create free account
hub / github.com/ceph/ceph / load

Method load

src/mgr/StandbyPyModules.cc:100–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98}
99
100int 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
126bool StandbyPyModule::get_config(const std::string &key,
127 std::string *value) const

Callers 1

start_oneMethod · 0.45

Calls 3

handle_pyerrorFunction · 0.85
get_nameFunction · 0.50
c_strMethod · 0.45

Tested by

no test coverage detected