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

Method notify_clog

src/mgr/ActivePyModule.cc:92–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90}
91
92void ActivePyModule::notify_clog(const LogEntry &log_entry)
93{
94 if (is_dead()) {
95 dout(5) << "cancelling notify_clog" << dendl;
96 return;
97 }
98
99 ceph_assert(pClassInstance != nullptr);
100
101 Gil gil(py_module->pMyThreadState, true);
102
103 // Construct python-ized LogEntry
104 PyFormatter f;
105 log_entry.dump(&f);
106 auto py_log_entry = f.get();
107
108 auto _start = ceph::mono_clock::now();
109 // Execute
110 auto pValue = PyObject_CallMethod(pClassInstance,
111 const_cast<char*>("notify"), const_cast<char*>("(sN)"),
112 "clog", py_log_entry);
113
114 if (pValue != NULL) {
115 Py_DECREF(pValue);
116 if (py_module->perfcounter) {
117 auto duration = ceph::mono_clock::now() - _start;
118 auto usec = std::chrono::duration_cast<std::chrono::microseconds>(duration).count();
119 py_module->perfcounter->inc(py_module->l_pym_notify_avg_usec, usec);
120 }
121 } else {
122 derr << get_name() << ".notify_clog:" << dendl;
123 derr << handle_pyerror(true, get_name(), "ActivePyModule::notify_clog") << dendl;
124 // FIXME: callers can't be expected to handle a python module
125 // that has spontaneously broken, but Mgr() should provide
126 // a hook to unload misbehaving modules when they have an
127 // error somewhere like this
128 }
129}
130
131bool ActivePyModule::method_exists(const std::string &method) const
132{

Callers 1

notify_allMethod · 0.80

Calls 7

handle_pyerrorFunction · 0.85
nowFunction · 0.50
get_nameFunction · 0.50
dumpMethod · 0.45
getMethod · 0.45
countMethod · 0.45
incMethod · 0.45

Tested by

no test coverage detected