mirror of
https://gitlab.com/libvirt/libvirt-python.git
synced 2025-07-14 16:59:34 +03:00
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: Wojtek Porczyk <woju@invisiblethingslab.com>
This commit is contained in:
committed by
Daniel P. Berrange
parent
72e237f7b9
commit
e985010674
12
setup.py
12
setup.py
@ -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)
|
||||
|
||||
|
Reference in New Issue
Block a user