[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v2 3/3] python: Add binding for non-blocking xs_check_watch()
On Thu, Sep 21, 2017 at 05:47:08PM +0100, Euan Harris wrote: > xs_check_watch() checks for watch notifications without blocking. > Together with the binding for xs_fileno(), this makes it possible > to write event-driven clients in Python. > > Signed-off-by: Euan Harris <euan.harris@xxxxxxxxxx> > Reviewed-by: Wei Liu <wei.liu2@xxxxxxxxxx> Acked-by: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx> > --- > tools/python/xen/lowlevel/xs/xs.c | 28 ++++++++++++++++++++++++++++ > 1 file changed, 28 insertions(+) > > diff --git a/tools/python/xen/lowlevel/xs/xs.c > b/tools/python/xen/lowlevel/xs/xs.c > index 2af5e07..4710002 100644 > --- a/tools/python/xen/lowlevel/xs/xs.c > +++ b/tools/python/xen/lowlevel/xs/xs.c > @@ -474,6 +474,33 @@ static PyObject *xspy_fileno(XsHandle *self) > } > > > +#define xspy_check_watch_doc "\n" \ > + "Check for watch notifications without blocking.\n" \ > + "\n" \ > + "Returns: [tuple] (path, token).\n" \ > + " None if no watches have fired.\n" \ > + "Raises xen.lowlevel.xs.Error on error.\n" \ > + "\n" > + > +static PyObject *xspy_check_watch(XsHandle *self, PyObject *args) > +{ > + struct xs_handle *xh = xshandle(self); > + PyObject *val = NULL; > + char **xsval; > + > + if (!xh) > + return NULL; > + > + xsval = xs_check_watch(xh); > + if (!xsval) { > + return none(errno == EAGAIN); > + } > + > + val = match_watch_by_token(self, xsval); > + free(xsval); > + return val; > +} > + > #define xspy_read_watch_doc "\n" \ > "Read a watch notification.\n" \ > "\n" \ > @@ -911,6 +938,7 @@ static PyMethodDef xshandle_methods[] = { > XSPY_METH(set_permissions, METH_VARARGS), > XSPY_METH(watch, METH_VARARGS), > XSPY_METH(read_watch, METH_NOARGS), > + XSPY_METH(check_watch, METH_NOARGS), > XSPY_METH(unwatch, METH_VARARGS), > XSPY_METH(transaction_start, METH_NOARGS), > XSPY_METH(transaction_end, METH_VARARGS | METH_KEYWORDS), -- Best Regards, Marek Marczykowski-Górecki Invisible Things Lab A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? Attachment:
signature.asc _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |