| 90 | } |
| 91 | |
| 92 | void 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 | |
| 131 | bool ActivePyModule::method_exists(const std::string &method) const |
| 132 | { |
no test coverage detected