From aeb40454161923ba5a6e065532d7d7a74ce1e008 Mon Sep 17 00:00:00 2001 From: Tristan Cacqueray Date: Thu, 18 Jan 2018 01:24:09 +0000 Subject: [PATCH] zk: check for client in properties This change prevents this exception happening randomly in test teardown: AttributeError: 'NoneType' object has no attribute 'state' Change-Id: If1eff3038f5d98d5e9f28fba82d881e0f987c266 --- nodepool/zk.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nodepool/zk.py b/nodepool/zk.py index ca894cd16..dc5cbcaa9 100755 --- a/nodepool/zk.py +++ b/nodepool/zk.py @@ -715,14 +715,20 @@ class ZooKeeper(object): @property def connected(self): + if self.client is None: + return False return self.client.state == KazooState.CONNECTED @property def suspended(self): + if self.client is None: + return True return self.client.state == KazooState.SUSPENDED @property def lost(self): + if self.client is None: + return True return self.client.state == KazooState.LOST @property