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