Antoni Segura Puimedon has posted comments on this change.
Change subject: PARTIAL: explicitly close libvirt connection after use ......................................................................
Patch Set 1: I would prefer that you didn't submit this
I'd rather modify the connection object in libvirtconnection.py in the following way:
Top of the module:
import new
and before return connection do:
connection.__enter__ = new.instancemethod(lambda self: self, connection, connection.__class__) def conn_close(self, *args): self.close()
connection.__exit__ = new.instancemethod(conn_close, connection, connection.__class__)
This will allow the current usage as well as:
with libvirtconnection.get() as conn: conn.xxxx
and automatically close.