summaryrefslogtreecommitdiff
path: root/libvirtaio.py
Commit message (Collapse)AuthorAgeFilesLines
* libvirtaio: Fix compat with python 3.7Cole Robinson2018-06-271-4/+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>
* libvirtaio: add .drain() coroutineWojtek Porczyk2017-09-261-2/+34
| | | | | | | | 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>
* libvirtaio: keep track of the current implementationWojtek Porczyk2017-09-261-2/+14
| | | | | | | | 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>
* libvirtaio: fix closing of the objectsWojtek Porczyk2017-09-261-6/+1
| | | | | | | | - 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>
* libvirtaio: do not double-add callbacksWojtek Porczyk2017-09-261-5/+4
| | | | | | | 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>
* libvirtaio: cache the list of callbacks when callingWojtek Porczyk2017-09-261-1/+1
| | | | | | | | | | | | | | | | | | | 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>
* libvirtaio: add more debug loggingWojtek Porczyk2017-09-261-8/+25
| | | | | | | This logging is helpful for tracing problems with unclosed connections and leaking file descriptors. Signed-off-by: Wojtek Porczyk <woju@invisiblethingslab.com>
* Add asyncio event loop implementationWojtek Porczyk2017-04-041-0/+399
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>