Commit e9850106 authored by Wojtek Porczyk's avatar Wojtek Porczyk Committed by Daniel P. Berrange

Add asyncio event loop implementation

This is usable only on python >= 3.4 (or 3.3 with out-of-tree asyncio),
however it should be harmless for anyone with older python versions.

In simplest case, to have the callbacks queued on the default loop:

    >>> import libvirtaio
    >>> libvirtaio.virEventRegisterAsyncIOImpl()

The function is not present on non-compatible platforms.
Signed-off-by: 's avatarWojtek Porczyk <woju@invisiblethingslab.com>
parent 72e237f7
......@@ -31,6 +31,7 @@ include libvirt-qemu-override-api.xml
include libvirt-qemu-override.c
include libvirt-utils.h
include libvirt-utils.c
include libvirtaio.py
include MANIFEST
include README
include sanitytest.py
......
......@@ -86,11 +86,13 @@ rm -f %{buildroot}%{_libdir}/python*/site-packages/*egg-info
%defattr(-,root,root)
%doc ChangeLog AUTHORS NEWS README COPYING COPYING.LESSER examples/
%{_libdir}/python3*/site-packages/libvirt.py*
%{_libdir}/python3*/site-packages/libvirtaio.py*
%{_libdir}/python3*/site-packages/libvirt_qemu.py*
%{_libdir}/python3*/site-packages/libvirt_lxc.py*
%{_libdir}/python3*/site-packages/__pycache__/libvirt.cpython-*.py*
%{_libdir}/python3*/site-packages/__pycache__/libvirt_qemu.cpython-*.py*
%{_libdir}/python3*/site-packages/__pycache__/libvirt_lxc.cpython-*.py*
%{_libdir}/python3*/site-packages/__pycache__/libvirtaio.cpython-*.py*
%{_libdir}/python3*/site-packages/libvirtmod*
%endif
......
This diff is collapsed.
......@@ -14,6 +14,7 @@ import sys
import os
import os.path
import re
import shutil
import time
MIN_LIBVIRT = "0.9.11"
......@@ -50,6 +51,12 @@ def have_libvirt_lxc():
except DistutilsExecError:
return False
def have_libvirtaio():
# This depends on asyncio, which in turn depends on "yield from" syntax.
# The asyncio module itself is in standard library since 3.4, but there is
# an out-of-tree version compatible with 3.3.
return sys.version_info >= (3, 3)
def get_pkgconfig_data(args, mod, required=True):
"""Run pkg-config to and return content associated with it"""
f = os.popen("%s %s %s" % (get_pkgcfg(), " ".join(args), mod))
......@@ -124,6 +131,9 @@ def get_module_lists():
c_modules.append(modulelxc)
py_modules.append("libvirt_lxc")
if have_libvirtaio():
py_modules.append("libvirtaio")
return c_modules, py_modules
......@@ -141,6 +151,8 @@ class my_build(build):
self.spawn([sys.executable, "generator.py", "libvirt-qemu", apis[1]])
if have_libvirt_lxc():
self.spawn([sys.executable, "generator.py", "libvirt-lxc", apis[2]])
if have_libvirtaio():
shutil.copy('libvirtaio.py', 'build')
build.run(self)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment