From 929923164eebbb1f01171b0c08dd596bfa7a4ade Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Wed, 10 Feb 2016 16:44:49 +0100 Subject: [PATCH] Move libvirt_conn.close to object destructor Process exit is too late for long-running processes. Especially tests, which create a lot of such objects which leads to depleting all the file descriptors. QubesOS/qubes-issues#1697 --- qubes/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/qubes/__init__.py b/qubes/__init__.py index 73a0ba14..c580efd5 100644 --- a/qubes/__init__.py +++ b/qubes/__init__.py @@ -125,7 +125,6 @@ class VMMConnection(object): if self._libvirt_conn is None: raise qubes.exc.QubesException('Failed connect to libvirt driver') libvirt.registerErrorHandler(self._libvirt_error_handler, None) - atexit.register(self._libvirt_conn.close) @__builtin__.property def libvirt_conn(self): @@ -165,6 +164,10 @@ class VMMConnection(object): self.init_vmm_connection() return self._xs + def __del__(self): + if self._libvirt_conn: + self._libvirt_conn.close() + class QubesHost(object): '''Basic information about host machine