(hopefully) fix race condition when data updates

This commit is contained in:
Joshua Boniface 2018-06-11 17:44:22 -04:00
parent d77373bb21
commit b3169758ff
1 changed files with 6 additions and 4 deletions

View File

@ -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):