[PATCH 1/1] Fix a trivial flake8 warning

Erik Skultety eskultet at redhat.com
Thu Feb 9 11:39:04 UTC 2023


On Thu, Feb 09, 2023 at 10:00:27AM +0100, Martin Kletzander wrote:
...
> > diff --git a/tools/virt-qemu-qmp-proxy b/tools/virt-qemu-qmp-proxy
> > index dfbaa1ff0c..2d9dd6495d 100755
> > --- a/tools/virt-qemu-qmp-proxy
> > +++ b/tools/virt-qemu-qmp-proxy
> > @@ -335,7 +335,7 @@ def main():
> >     sock.bind(args.sockpath)
> >     sock.listen(1)
> > 
> > -    _ = QMPProxy(conn, dom, sock, args.verbose)
> > +    QMPProxy(conn, dom, sock, args.verbose)
> > 
> 
> I don't think you can do that because the object could be garbage
> collected, but I'm not sure how much havoc would that cause...

Would it? Not advocating to accept the patch, but looking at the object it
passes a reference to itself to qemuMonitorEventRegister() so as long as the
monitor callback map exists the object should not be garbage collected. However
the usage of _ in this case is IMO quite unfortunate in that it's simply there
to really make sure Python holds one more explicit reference to the object. In
cases like these Python's context managers are used instead.

Erik



More information about the libvir-list mailing list