return f.get();
}
+PyObject *PyModules::get_context()
+{
+ PyThreadState *tstate = PyEval_SaveThread();
+ Mutex::Locker l(lock);
+ PyEval_RestoreThread(tstate);
+
+ // Construct a capsule containing ceph context.
+ // Not incrementing/decrementing ref count on the context because
+ // it's the global one and it has process lifetime.
+ auto capsule = PyCapsule_New(g_ceph_context, nullptr, nullptr);
+ return capsule;
+}
+
PyObject *get_counter_python(std::string const &handle,
entity_type_t svc_type, const std::string &svc_id,
const std::string &path);
+ PyObject *get_context();
std::map<std::string, std::string> config_cache;
return PyString_FromString(pretty_version_to_str().c_str());
}
+static PyObject *
+ceph_get_context(PyObject *self, PyObject *args)
+{
+ return global_handle->get_context();
+}
+
static PyObject*
get_counter(PyObject *self, PyObject *args)
{
"Emit a (local) log message"},
{"get_version", ceph_get_version, METH_VARARGS,
"Get the ceph version of this process"},
+ {"get_context", ceph_get_context, METH_NOARGS,
+ "Get a CephContext* in a python capsule"},
{NULL, NULL, 0, NULL}
};