From ad8971ecebc8258d84a1a358895c79acf16fdc90 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Mon, 26 Dec 2016 09:56:06 +0100 Subject: [PATCH] tests: minimize file descriptor leaks This is not perfect as we still rely on garbage collection to do its job and it seems it is not running often enough. --- tests/integration/fixtures/namespaces.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/integration/fixtures/namespaces.py b/tests/integration/fixtures/namespaces.py index 6257df22..e278bce1 100644 --- a/tests/integration/fixtures/namespaces.py +++ b/tests/integration/fixtures/namespaces.py @@ -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. -- 2.39.5