----- Original Message -----
From: "Nir Soffer" <nsoffer(a)redhat.com>
To: sanlock-devel(a)lists.fedorahosted.org
Sent: Monday, August 11, 2014 3:07:30 PM
Subject: [PATCH] python: add support for lockspace events
Add support for sending events to other hosts and listening for
lockspace events.
I added thin wrappers for sanlock_reg_event, sanlock_get_event,
sanlock_end_event, and sanlock_set_event.
Where sanlock C API has unused arguments, the Python bindings do not use
them, since we can add them later as optional arguments in a backward
compatible manner. This ensures that new code depending on this argument
will fail when working with a version that does not provide it.
sanlock_get_event returns one event per call. The Python version is
easier to use, returning list of events in one call, similar to
get_hosts.
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
python/sanlock.c | 260
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 260 insertions(+)
diff --git a/python/sanlock.c b/python/sanlock.c
index b62b8bc..ad8e179 100644
--- a/python/sanlock.c
+++ b/python/sanlock.c
@@ -1243,6 +1243,254 @@ py_exception_errno(PyObject *self,
PyBaseExceptionObject *exc_obj)
return exc_errno;
}
+/* reg_event */
+PyDoc_STRVAR(pydoc_reg_event, "\
+reg_event(lockspace) -> int\n\
+Register an event listener for lockspace and return an open file
descriptor\n\
+for waiting for lockspace events using poll. When the file descriptor
becomes\n\
This is not limited to poll (e.g. select, etc.).
+static PyObject *
+py_set_event(PyObject *self __unused, PyObject *args, PyObject *keywds)
+{
+ const char *lockspace;
+ struct sanlk_host_event he = {0};
+ uint32_t flags = 0;
+ int rv;
+
+ static char *kwlist[] = {"lockspace", "host_id",
"generation", "event",
+ "data", "flags", NULL};
+
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "skLL|Li", kwlist,
+ &lockspace, &he.host_id, &he.generation, &he.event,
&he.data,
+ &flags)) {
+ return NULL;
+ }
According to the types I think the format string should be "skkk|kI"
The rest seems ok. Thanks!
--
Federico