Re: [PATCH v2 2/6] libvirtaio: cache the list of callbacks when calling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Aug 31, 2017 at 09:20:40PM +0200, Wojtek Porczyk wrote:
> 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@xxxxxxxxxxxxxxxxxxxxxx>
> ---
>  libvirtaio.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libvirtaio.py b/libvirtaio.py
> index 46de9ab..d962e64 100644
> --- a/libvirtaio.py
> +++ b/libvirtaio.py
> @@ -96,7 +96,7 @@ class Descriptor(object):
>  
>          :param int event: The event (from libvirt's constants) being dispatched
>          '''
> -        for callback in self.callbacks.values():
> +        for callback in list(self.callbacks.values()):
>              if callback.event is not None and callback.event & event:
>                  callback.cb(callback.iden, self.fd, event, callback.opaque)

Reviewed-by: Daniel P. Berrange <berrange@xxxxxxxxxx>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux