📜 ⬆️ ⬇️

pyxs - library for xenstore on python

Introduction: The key element of all tulbs for Xen is xenstore, a service that allows you to have a “common database” for all domains on a host. A long time ago, there was a libxs library for accessing it from C applications. There is a python binding to it (xen.lowlevel.xs), however, he has very serious problems with a multi-threaded event subscription. This did not suit us and the pyxs library was written for the operation of memory on demand, which allows us to have very comfortable work with xenstore, multi-threaded subscriptions, etc.

By common thought, it was decided to give it to people under the LGPL-license.

Examples of using

Simple reading and writing:
 from pyxs import client

 xs = Client ():
 xs ["/ foobar / a"] = "baz"
 print xs ["/ foobar / a"]

')
The second important class is Monitor for organizing a subscription to multiple changes, for which everything was written:

 from pyxs import Monitor

 xs = Monitor ():
 xs.watch ("/ local / domain / 1")
 xs.watch ("/ local / domain / 2")
 while true:
     print xs.wait ()

We will be awakened every time something changes in the first OR second way.

Link to github: github.com/selectel/pyxs
Documentation: pyxs.readthedocs.org

Source: https://habr.com/ru/post/134722/


All Articles