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
|
|
@ -70,6 +70,7 @@ class LoopServer:
|
|||
try:
|
||||
lo.set_fd(fd)
|
||||
except OSError as e:
|
||||
lo.close()
|
||||
if e.errno == errno.EBUSY:
|
||||
continue
|
||||
raise e
|
||||
|
|
@ -108,6 +109,8 @@ class LoopServer:
|
|||
def __exit__(self, *args):
|
||||
self.event_loop.call_soon_threadsafe(self.event_loop.stop)
|
||||
self.thread.join()
|
||||
for lo in self.devs:
|
||||
lo.close()
|
||||
|
||||
|
||||
class LoopClient:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue