From 34fb851c334d1316231a5006c04c0586dc64e15d Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Wed, 6 Jun 2018 01:24:28 -0400 Subject: [PATCH] Add try blocks around decode functions for when a new daemon is created --- NodeInstance.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/NodeInstance.py b/NodeInstance.py index efcbb078..e5a88f84 100644 --- a/NodeInstance.py +++ b/NodeInstance.py @@ -21,7 +21,11 @@ class NodeInstance(threading.Thread): # Zookeeper handlers for changed states @zk.DataWatch(self.zkey + '/state') def watch_hypervisor_state(data, stat, event=""): - self.state = data.decode('ascii') + try: + self.state = data.decode('ascii') + except AttributeError: + self.state = 'stop' + if self.state == 'flush': self.flush() if self.state == 'unflush': @@ -29,11 +33,17 @@ class NodeInstance(threading.Thread): @zk.DataWatch(self.zkey + '/memfree') def watch_hypervisor_memfree(data, stat, event=""): - self.memfree = data.decode('ascii') + try: + self.memfree = data.decode('ascii') + except AttributeError: + self.memfree = 0 @zk.DataWatch(self.zkey + '/runningdomains') def watch_hypervisor_runningdomains(data, stat, event=""): - self.domain_list = data.decode('ascii').split() + try: + self.domain_list = data.decode('ascii').split() + except AttributeError: + self.domain_list = [] # Get value functions def getfreemem(self):