diff options
author | Philipp Hahn <hahn@univention.de> | 2020-04-20 11:58:17 +0200 |
---|---|---|
committer | Philipp Hahn <hahn@univention.de> | 2020-08-06 08:50:37 +0200 |
commit | 6b9728173069969724dc8bd410cef9bbe7e1ceea (patch) | |
tree | 756df302caac741a887e658b657ad843dca08b42 /libvirtaio.py | |
parent | 12d631d11aae5895938b0fa0c02bbc186c50b79f (diff) | |
download | libvirt-python-6b9728173069969724dc8bd410cef9bbe7e1ceea.tar.gz |
libvirtaio: assert callback type
self.callbacks contains a mix of FDCallback and TimeoutCallback, while
the update code does not explicitly check for.
Signed-off-by: Philipp Hahn <hahn@univention.de>
Diffstat (limited to 'libvirtaio.py')
-rw-r--r-- | libvirtaio.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libvirtaio.py b/libvirtaio.py index bb76e35..e4177d0 100644 --- a/libvirtaio.py +++ b/libvirtaio.py @@ -373,7 +373,9 @@ class virEventAsyncIOImpl(object): https://libvirt.org/html/libvirt-libvirt-event.html#virEventUpdateHandleFunc ''' self.log.debug('update_handle(watch=%d, event=%d)', watch, event) - self.callbacks[watch].update(event=event) + callback = self.callbacks[watch] + assert isinstance(callback, FDCallback) + callback.update(event=event) def _remove_handle(self, watch): '''Unregister a callback from a file handle. @@ -390,6 +392,7 @@ class virEventAsyncIOImpl(object): except KeyError as err: self.log.warning('remove_handle(): no such handle: %r', err.args[0]) return -1 + assert isinstance(callback, FDCallback) fd = callback.descriptor.fd assert callback is self.descriptors[fd].remove_handle(watch) if len(self.descriptors[fd].callbacks) == 0: @@ -429,7 +432,9 @@ class virEventAsyncIOImpl(object): https://libvirt.org/html/libvirt-libvirt-event.html#virEventUpdateTimeoutFunc ''' self.log.debug('update_timeout(timer=%d, timeout=%d)', timer, timeout) - self.callbacks[timer].update(timeout=timeout) + callback = self.callbacks[timer] + assert isinstance(callback, TimeoutCallback) + callback.update(timeout=timeout) def _remove_timeout(self, timer): '''Unregister a callback for a timer |