From 2256f2e2ac90edb0fc5dd8de96f4e7bf2aa14d65 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Isma=C3=ABl=20Bouya?= Date: Sun, 27 Jun 2021 02:16:45 +0200 Subject: [PATCH] Only initiate connection on demand for buildbot workers --- modules/private/buildbot/common/libvirt.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/private/buildbot/common/libvirt.py b/modules/private/buildbot/common/libvirt.py index 85fd908..e250627 100644 --- a/modules/private/buildbot/common/libvirt.py +++ b/modules/private/buildbot/common/libvirt.py @@ -154,7 +154,19 @@ class Connection: def __init__(self, uri): self.uri = uri - self.connection = libvirt.open(uri) + self._connection = None + + @property + def connection(self): + if self._connection is not None: + try: + if not self._connection.isAlive(): + self._connection = None + except: + self._connection = None + if self._connection is None: + self._connection = libvirt.open(self.uri) + return self._connection @defer.inlineCallbacks def create(self, xml): -- 2.41.0