Bug 717786

Summary: libguestfs python bindings should have an explicit close call
Product: [Community] Virtualization Tools Reporter: Richard W.M. Jones <rjones>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED UPSTREAM QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: alevy, mbooth, virt-maint
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-06-30 09:17:28 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Richard W.M. Jones 2011-06-29 20:54:07 UTC
Description of problem:

It's not always possible to tell if there is a dangling
reference to the libguestfs handle somewhere in a program.
In order to ensure that the handle is really closed, it's
a good idea to have an explicit close call.  Perl, Ruby
and OCaml bindings already have this.

Version-Release number of selected component (if applicable):

libguestfs 1.11.12

How reproducible:

Always.

Steps to Reproduce:

Compare the following programs and their output:

$ python -c 'import guestfs; g = guestfs.GuestFS(); g.set_trace(1);
             del g; print "ok"'
libguestfs: trace: close
ok
$ python -c 'import guestfs; g = guestfs.GuestFS(); g.set_trace(1);
             g2 = g; del g; print "ok"'
ok
libguestfs: trace: close

Comment 1 Richard W.M. Jones 2011-06-30 09:17:28 UTC
Fix included in libguestfs git:

http://git.annexia.org/?p=libguestfs.git;a=commitdiff;h=8c5bdc3e12947580e91c018b71adf9ad3128bb75

To close the handle explicitly in a way which will work
with older versions of libguestfs too, do:

try:
  g.close()
except AttributeError:
  pass
del g