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

Method load

src/mgr/ActivePyModule.cc:32–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30using namespace std::literals;
31
32int ActivePyModule::load(ActivePyModules *py_modules)
33{
34 ceph_assert(py_modules);
35 Gil gil(py_module->pMyThreadState, true);
36
37 // We tell the module how we name it, so that it can be consistent
38 // with us in logging etc.
39 auto pThisPtr = PyCapsule_New(this, nullptr, nullptr);
40 auto pPyModules = PyCapsule_New(py_modules, nullptr, nullptr);
41 auto pModuleName = PyUnicode_FromString(get_name().c_str());
42 auto pArgs = PyTuple_Pack(3, pModuleName, pPyModules, pThisPtr);
43
44 pClassInstance = PyObject_CallObject(py_module->pClass, pArgs);
45 Py_DECREF(pModuleName);
46 Py_DECREF(pArgs);
47 if (pClassInstance == nullptr) {
48 derr << "Failed to construct class in '" << get_name() << "'" << dendl;
49 derr << handle_pyerror(true, get_name(), "ActivePyModule::load") << dendl;
50 return -EINVAL;
51 } else {
52 dout(1) << "Constructed class from module: " << get_name() << dendl;
53 }
54
55 return 0;
56}
57
58void ActivePyModule::notify(const std::string &notify_type, const std::string &notify_id)
59{

Callers

nothing calls this directly

Calls 3

handle_pyerrorFunction · 0.85
get_nameFunction · 0.50
c_strMethod · 0.45

Tested by

no test coverage detected