Skip to content

python: Add non-blocking Xenstore watch bindings

Euan Harris xen-devel 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest3 patches 2 repliesIn review
  2. v23 patches 3 repliesSuperseded
  3. v13 patches 4 repliesSuperseded

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3python: Add binding for xs_fileno()tools/python/xen/lowlevel/xs/xs.c+20 -02 replies
2/3python: Extract registered watch search logic from xspy_read_watch()tools/python/xen/lowlevel/xs/xs.c+37 -230 replies
3/3python: Add binding for non-blocking xs_check_watch()tools/python/xen/lowlevel/xs/xs.c+28 -00 replies

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchKonrad Rzeszutek WilkWei LiuMarek Marczykowski-Górecki
1/3R-b R-b A-b
2/3R-b A-b
3/3R-b A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v3 thread

Cover letter [PATCH v3 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 binding 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 | 108 ++++++++++++++++++++++++++++++--------
 1 file changed, 85 insertions(+), 23 deletions(-)
Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel