From: Vincent Bernat Date: Mon, 26 Dec 2016 08:56:06 +0000 (+0100) Subject: tests: minimize file descriptor leaks X-Git-Tag: 0.9.6~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ad8971ecebc8258d84a1a358895c79acf16fdc90;p=thirdparty%2Flldpd.git 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. --- 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.