From b3169758ff4b96c0ff150a8255e00afc43ea9058 Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Mon, 11 Jun 2018 17:44:22 -0400 Subject: [PATCH] (hopefully) fix race condition when data updates --- VMInstance.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/VMInstance.py b/VMInstance.py index 46cfd8b1..f6cdf1fe 100644 --- a/VMInstance.py +++ b/VMInstance.py @@ -48,9 +48,10 @@ class VMInstance: print(data.decode('ascii')) try: self.hypervisor = data.decode('ascii') + self.state = self.zk.get('/domains/{}/state'.format(self.domuuid)) + self.manage_vm_state() except: - return - self.manage_vm_state() + pass # Watch for changes to the state field in Zookeeper @zk.DataWatch('/domains/{}/state'.format(self.domuuid)) @@ -58,9 +59,10 @@ class VMInstance: print(data.decode('ascii')) try: self.state = data.decode('ascii') + self.hypervisor = self.zk.get('/domains/{}/hypervisor'.format(self.domuuid)) + self.manage_vm_state() except: - return - self.manage_vm_state() + pass # Get data functions def getstate(self):