]> git.ipfire.org Git - thirdparty/lldpd.git/blobdiff - tests/integration/fixtures/namespaces.py
tests: minimize file descriptor leaks
[thirdparty/lldpd.git] / tests / integration / fixtures / namespaces.py
index 6257df220dd52054854840e19b1d528fa7de9f4f..e278bce1c46af689e1a45922a2df83a7c03f7877 100644 (file)
@@ -81,8 +81,17 @@ class Namespace(object):
         os.close(self.pipe[0])
         if 'pid' not in namespaces:
             os.close(self.pipe[1])
+            self.pipe = None
             os.waitpid(pid, 0)
 
+    def __del__(self):
+        for fd in self.next:
+            os.close(fd)
+        for fd in self.previous:
+            os.close(fd)
+        if self.pipe is not None:
+            os.close(self.pipe[1])
+
     def child(self):
         """Cloned child.