From: Ismaƫl Bouya Date: Sun, 27 Jun 2021 00:16:45 +0000 (+0200) Subject: Only initiate connection on demand for buildbot workers X-Git-Url: https://git.immae.eu/?p=perso%2FImmae%2FConfig%2FNix.git;a=commitdiff_plain;h=2256f2e2ac90edb0fc5dd8de96f4e7bf2aa14d65 Only initiate connection on demand for buildbot workers --- 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):