Bug 717786 - libguestfs python bindings should have an explicit close call
libguestfs python bindings should have an explicit close call
Status: CLOSED UPSTREAM
Product: Virtualization Tools
Classification: Community
Component: libguestfs (Show other bugs)
unspecified
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Richard W.M. Jones
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2011-06-29 16:54 EDT by Richard W.M. Jones
Modified: 2011-06-30 05:17 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2011-06-30 05:17:28 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Richard W.M. Jones 2011-06-29 16:54:07 EDT
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 05:17:28 EDT
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

Note You need to log in before you can comment on or make changes to this bug.