| 56 | } |
| 57 | |
| 58 | void ActivePyModule::notify(const std::string ¬ify_type, const std::string ¬ify_id) |
| 59 | { |
| 60 | if (is_dead()) { |
| 61 | dout(5) << "cancelling notify " << notify_type << " " << notify_id << dendl; |
| 62 | return; |
| 63 | } |
| 64 | |
| 65 | ceph_assert(pClassInstance != nullptr); |
| 66 | |
| 67 | Gil gil(py_module->pMyThreadState, true); |
| 68 | |
| 69 | auto _start = ceph::mono_clock::now(); |
| 70 | // Execute |
| 71 | auto pValue = PyObject_CallMethod(pClassInstance, |
| 72 | const_cast<char*>("notify"), const_cast<char*>("(ss)"), |
| 73 | notify_type.c_str(), notify_id.c_str()); |
| 74 | |
| 75 | if (pValue != NULL) { |
| 76 | Py_DECREF(pValue); |
| 77 | if (py_module->perfcounter) { |
| 78 | auto duration = ceph::mono_clock::now() - _start; |
| 79 | auto usec = std::chrono::duration_cast<std::chrono::microseconds>(duration).count(); |
| 80 | py_module->perfcounter->inc(py_module->l_pym_notify_avg_usec, usec); |
| 81 | } |
| 82 | } else { |
| 83 | derr << get_name() << ".notify:" << dendl; |
| 84 | derr << handle_pyerror(true, get_name(), "ActivePyModule::notify") << dendl; |
| 85 | // FIXME: callers can't be expected to handle a python module |
| 86 | // that has spontaneously broken, but Mgr() should provide |
| 87 | // a hook to unload misbehaving modules when they have an |
| 88 | // error somewhere like this |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | void ActivePyModule::notify_clog(const LogEntry &log_entry) |
| 93 | { |