On Fri, Mar 17, 2017 at 02:16:37AM +0100, Wojtek Porczyk wrote:
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 libvirt
>>> libvirt.virEventRegisterAsyncIOImpl()
The function is not present on non-compatible platforms.
Signed-off-by: Wojtek Porczyk <woju(a)invisiblethingslab.com>
---
libvirt-override.py | 6 +
libvirt-python.spec.in | 1 +
libvirtaio.py | 398 +++++++++++++++++++++++++++++++++++++++++++++++++
sanitytest.py | 2 +-
setup.py | 12 ++
5 files changed, 418 insertions(+), 1 deletion(-)
create mode 100644 libvirtaio.py
diff --git a/libvirt-override.py b/libvirt-override.py
index 3d09d63..6a28336 100644
--- a/libvirt-override.py
+++ b/libvirt-override.py
@@ -16,6 +16,12 @@ except ImportError:
if str(cyg_e).count("No module named"):
raise lib_e
+try:
+ from libvirtaio import virEventAsyncIOImpl, virEventRegisterAsyncIOImpl
+except (ImportError, SyntaxError):
+ # python < 3.3, or 3.3 and no out-of-tree asyncio
+ pass
+
I don't think we need this really. IMHO apps can simply do
'import libvirtaio' directly if they know they're using a
python new enough for asyncio.
diff --git a/libvirtaio.py b/libvirtaio.py
new file mode 100644
index 0000000..44c9a5b
--- /dev/null
+++ b/libvirtaio.py
@@ -0,0 +1,398 @@
+#
+# Copyright 2017 Wojtek Porczyk <woju(a)invisiblethingslab.com>
+#
+# Licensed under the Apache License, Version 2.0 (the 'License');
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#
http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an 'AS IS' BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
The libvirt python module is distributed under the LGPLv2+. Could you
resubmit this with that license header fixed.
Regards,
Daniel
--
|:
http://berrange.com -o-
http://www.flickr.com/photos/dberrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org :|
|:
http://entangle-photo.org -o-
http://search.cpan.org/~danberr/ :|