]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Only initiate connection on demand for buildbot workers
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Sun, 27 Jun 2021 00:16:45 +0000 (02:16 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Sun, 27 Jun 2021 00:16:45 +0000 (02:16 +0200)
modules/private/buildbot/common/libvirt.py

index 85fd90815a69d3011827f2ef7a4b32b2572fa1c7..e25062744ca2ec5e332f711770d35431ea80b6a6 100644 (file)
@@ -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):