1
0
mirror of https://gitlab.com/libvirt/libvirt-python.git synced 2025-07-18 04:59:33 +03:00
Commit Graph

8 Commits

Author SHA1 Message Date
e27528204c libvirtaio: Fix compat with python 3.7
In python 3.7, async is now a keyword, so this throws a syntax error:

  File "/usr/lib64/python3.7/site-packages/libvirtaio.py", line 49
    from asyncio import async as ensure_future
                            ^
  SyntaxError: invalid syntax

Switch to getattr trickery to accomplish the same goal

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2018-06-27 10:07:39 -04:00
f70939fc3e libvirtaio: add .drain() coroutine
The intended use is to ensure that the implementation is empty, which is
one way to ensure that all connections were properly closed and file
descriptors reclaimed.

Signed-off-by: Wojtek Porczyk <woju@invisiblethingslab.com>
2017-09-26 11:01:33 +01:00
7f1994ff46 libvirtaio: keep track of the current implementation
Since 7534c19 it is not possible to register event implementation twice.
Instead, allow for retrieving the current one, should it be needed
afterwards.

Signed-off-by: Wojtek Porczyk <woju@invisiblethingslab.com>
2017-09-26 11:01:33 +01:00
fc482fc868 libvirtaio: fix closing of the objects
- Descriptor.close() was a dead code, never used.
- TimeoutCallback.close(), as a cleanup function, should have called
    super() as last statement, not first

Signed-off-by: Wojtek Porczyk <woju@invisiblethingslab.com>
2017-09-26 11:01:33 +01:00
cc82a94528 libvirtaio: do not double-add callbacks
This was a harmless bug, without any impact, but it is wrong to manage
the collection of callbacks from it's members.

Signed-off-by: Wojtek Porczyk <woju@invisiblethingslab.com>
2017-09-26 11:01:33 +01:00
a5cc6da2c8 libvirtaio: cache the list of callbacks when calling
When the callback causes something that results in changes wrt
registered handles, python aborts iteration.

Relevant error message:

    Exception in callback None()
    handle: <Handle cancelled>
    Traceback (most recent call last):
      File "/usr/lib64/python3.5/asyncio/events.py", line 126, in _run
        self._callback(*self._args)
      File "/usr/lib64/python3.5/site-packages/libvirtaio.py", line 99, in _handle
        for callback in self.callbacks.values():
    RuntimeError: dictionary changed size during iteration

QubesOS/qubes-issues#2805
Signed-off-by: Wojtek Porczyk <woju@invisiblethingslab.com>
2017-09-26 11:01:33 +01:00
f7e5a9a085 libvirtaio: add more debug logging
This logging is helpful for tracing problems with unclosed connections
and leaking file descriptors.

Signed-off-by: Wojtek Porczyk <woju@invisiblethingslab.com>
2017-09-26 11:01:33 +01:00
e985010674 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>
2017-04-04 15:28:50 +01:00