[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 0/3] python: Add non-blocking Xenstore watch bindings
Expose xs_fileno() and xs_check_watch() to Python. These functions make it posible to write event-driven Xenstore clients in Python: #!/usr/bin/env python import xen.lowlevel.xs import sys import errno from select import select import time # Connect to XenStore and set watch xsh = xen.lowlevel.xs.xs() xsh.watch("/foo", "footoken") xsh.watch("/bar", "bartoken") # Start polling loop xsfd = xsh.fileno() while True: readable, writable, exceptional = select([xsfd], [], [xsfd], 1.0) print "%d tick" % time.time() if readable: while True: watch = xsh.check_watch() if not watch: break path, token = watch print "%d watch fired: path=%s, token=%s" % (time.time(), path, token) value = xsh.read("", path) print "%d read %s = %s" % (time.time(), path, value) if exceptional: print "select error" The polling loop can be simplified further by wrapping the call to xsh.check_watch() in a generator, but this is easier to do in Python than in the C bindings. Euan Harris (3): python: Add wrapper for xs_fileno() python: Extract registered watch search logic from xspy_read_watch() python: Add binding for non-blocking xs_check_watch() tools/python/xen/lowlevel/xs/xs.c | 109 ++++++++++++++++++++++++++++++-------- 1 file changed, 86 insertions(+), 23 deletions(-) -- 1.8.3.1 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |