summaryrefslogtreecommitdiff
path: root/libvirtaio.py
diff options
context:
space:
mode:
authorPhilipp Hahn <hahn@univention.de>2018-11-20 08:34:48 +0100
committerPhilipp Hahn <hahn@univention.de>2020-08-06 08:50:37 +0200
commit0ca8dc6340a85d0cb021d860a166ad4b92251d23 (patch)
tree907069ac431a9de9bc1590e58c90d35bee852cbe /libvirtaio.py
parent7c93891420a8df6d6b6e3f141548c6dae6664789 (diff)
downloadlibvirt-python-0ca8dc6340a85d0cb021d860a166ad4b92251d23.tar.gz
Normalize white space
indent by 4 spaces one spaces around assignments Signed-off-by: Philipp Hahn <hahn@univention.de>
Diffstat (limited to 'libvirtaio.py')
-rw-r--r--libvirtaio.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/libvirtaio.py b/libvirtaio.py
index f1811c1..1e8b0c7 100644
--- a/libvirtaio.py
+++ b/libvirtaio.py
@@ -78,6 +78,7 @@ class Callback(object):
self.impl.log.debug('callback %d close(), scheduling ff', self.iden)
self.impl.schedule_ff_callback(self.iden, self.opaque)
+
#
# file descriptors
#
@@ -114,8 +115,8 @@ class Descriptor(object):
# For the edge case of empty callbacks, any() returns False.
if any(callback.event & ~(
- libvirt.VIR_EVENT_HANDLE_READABLE |
- libvirt.VIR_EVENT_HANDLE_WRITABLE)
+ libvirt.VIR_EVENT_HANDLE_READABLE |
+ libvirt.VIR_EVENT_HANDLE_WRITABLE)
for callback in self.callbacks.values()):
warnings.warn(
'The only event supported are VIR_EVENT_HANDLE_READABLE '
@@ -161,6 +162,7 @@ class Descriptor(object):
self.update()
return callback
+
class DescriptorDict(dict):
'''Descriptors collection
@@ -175,6 +177,7 @@ class DescriptorDict(dict):
self[fd] = descriptor
return descriptor
+
class FDCallback(Callback):
'''Callback for file descriptor (watcher)
@@ -197,6 +200,7 @@ class FDCallback(Callback):
self.event = event
self.descriptor.update()
+
#
# timeouts
#
@@ -242,7 +246,7 @@ class TimeoutCallback(Callback):
if self.timeout >= 0 and self._task is None:
self.impl.log.debug('timer %r start', self.iden)
self._task = ensure_future(self._timer(),
- loop=self.impl.loop)
+ loop=self.impl.loop)
elif self.timeout < 0 and self._task is not None:
self.impl.log.debug('timer %r stop', self.iden)
@@ -254,6 +258,7 @@ class TimeoutCallback(Callback):
self.update(timeout=-1)
super(TimeoutCallback, self).close()
+
#
# main implementation
#
@@ -298,7 +303,7 @@ class virEventAsyncIOImpl(object):
# pylint: disable=bad-whitespace
self.log.debug('register()')
libvirt.virEventRegisterImpl(
- self._add_handle, self._update_handle, self._remove_handle,
+ self._add_handle, self._update_handle, self._remove_handle,
self._add_timeout, self._update_timeout, self._remove_timeout)
return self
@@ -350,11 +355,11 @@ class virEventAsyncIOImpl(object):
https://libvirt.org/html/libvirt-libvirt-event.html#virEventAddHandleFuncFunc
'''
callback = FDCallback(self, cb, opaque,
- descriptor=self.descriptors[fd], event=event)
+ descriptor=self.descriptors[fd], event=event)
assert callback.iden not in self.callbacks
self.log.debug('add_handle(fd=%d, event=%d, cb=..., opaque=...) = %d',
- fd, event, callback.iden)
+ fd, event, callback.iden)
self.callbacks[callback.iden] = callback
self.descriptors[fd].add_handle(callback)
self._pending_inc()
@@ -410,7 +415,7 @@ class virEventAsyncIOImpl(object):
assert callback.iden not in self.callbacks
self.log.debug('add_timeout(timeout=%d, cb=..., opaque=...) = %d',
- timeout, callback.iden)
+ timeout, callback.iden)
self.callbacks[callback.iden] = callback
callback.update(timeout=timeout)
self._pending_inc()
@@ -448,10 +453,13 @@ class virEventAsyncIOImpl(object):
_current_impl = None
+
+
def getCurrentImpl():
'''Return the current implementation, or None if not yet registered'''
return _current_impl
+
def virEventRegisterAsyncIOImpl(loop=None):
'''Arrange for libvirt's callbacks to be dispatched via asyncio event loop