Commit b7f85610 authored by Richard W.M. Jones's avatar Richard W.M. Jones
Browse files

python: Add explicit h.close() method

Normally we allow the handle to go out of scope which closes the
handle through __del__.  But there was no way to explicitly close the
handle which made testing various corner cases difficult.

This commit adds an explicit close method, and incidentally modifies
the __del__ method so it doesn't double-free the underlying module
handle.

After calling the explicit close you must not call any other method on
the handle.  The handle will raise the new nbd.ClosedHandle exception
if you do this.

This code is largely copied from the libguestfs python bindings,
released under a compatible license.

See: https://listman.redhat.com/archives/libguestfs/2023-February/030873.html
Thanks: Eric Blake
parent da8887fd
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment