loop: explicitly close fds to loop devices
Don't wait until python's garbage collector closes the file descriptors to loop devices. Close them when the `LoopServer` context manager exits, after an assembler has finished running.
This commit is contained in:
parent
47dc1b5b92
commit
b487126bb8
2 changed files with 16 additions and 0 deletions
|
|
@ -108,6 +108,19 @@ class Loop:
|
|||
(not os.minor(info.st_rdev) == minor)):
|
||||
raise UnexpectedDevice(minor, info.st_rdev, info.st_mode)
|
||||
|
||||
def __del__(self):
|
||||
self.close()
|
||||
|
||||
def close(self):
|
||||
"""Close this loop device.
|
||||
|
||||
No operations on this object are valid after this call.
|
||||
"""
|
||||
if self.fd >= 0:
|
||||
os.close(self.fd)
|
||||
self.fd = -1
|
||||
self.devname = "<closed>"
|
||||
|
||||
def set_fd(self, fd):
|
||||
"""Bind a file descriptor to the loopback device
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue