Bug 717786 - libguestfs python bindings should have an explicit close call
Summary: libguestfs python bindings should have an explicit close call
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libguestfs
Version: unspecified
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Richard W.M. Jones
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-06-29 20:54 UTC by Richard W.M. Jones
Modified: 2011-06-30 09:17 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-06-30 09:17:28 UTC


Attachments (Terms of Use)

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


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