diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2021-06-27 02:16:45 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2021-06-27 02:16:45 +0200 |
commit | 2256f2e2ac90edb0fc5dd8de96f4e7bf2aa14d65 (patch) | |
tree | 753311ae5c9f6390214ad8713e9439870e927307 | |
parent | 6b017278cb0dff04fc6cde863a1bffa012ed5f59 (diff) | |
download | Nix-2256f2e2ac90edb0fc5dd8de96f4e7bf2aa14d65.tar.gz Nix-2256f2e2ac90edb0fc5dd8de96f4e7bf2aa14d65.tar.zst Nix-2256f2e2ac90edb0fc5dd8de96f4e7bf2aa14d65.zip |
Only initiate connection on demand for buildbot workers
-rw-r--r-- | modules/private/buildbot/common/libvirt.py | 14 |
1 files changed, 13 insertions, 1 deletions
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: | |||
154 | 154 | ||
155 | def __init__(self, uri): | 155 | def __init__(self, uri): |
156 | self.uri = uri | 156 | self.uri = uri |
157 | self.connection = libvirt.open(uri) | 157 | self._connection = None |
158 | |||
159 | @property | ||
160 | def connection(self): | ||
161 | if self._connection is not None: | ||
162 | try: | ||
163 | if not self._connection.isAlive(): | ||
164 | self._connection = None | ||
165 | except: | ||
166 | self._connection = None | ||
167 | if self._connection is None: | ||
168 | self._connection = libvirt.open(self.uri) | ||
169 | return self._connection | ||
158 | 170 | ||
159 | @defer.inlineCallbacks | 171 | @defer.inlineCallbacks |
160 | def create(self, xml): | 172 | def create(self, xml): |