From e765ec7f49197e28a639f64eb563e20908929e29 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Fri, 12 Jul 2019 00:44:25 -0400 Subject: [PATCH] Handle client connection falures gracefully --- client-common/common.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/client-common/common.py b/client-common/common.py index a97d14f1..3f058305 100644 --- a/client-common/common.py +++ b/client-common/common.py @@ -46,7 +46,14 @@ def validateUUID(dom_uuid): # def startZKConnection(zk_host): zk_conn = kazoo.client.KazooClient(hosts=zk_host) - zk_conn.start() + try: + zk_conn.start() + except kazoo.handlers.threading.KazooTimeoutError: + print('Timed out connecting to Zookeeper at "{}".'.format(zk_host)) + exit(1) + except Exception as e: + print('Failed to connect to Zookeeper at "{}": {}'.format(zk_host, e)) + exit(1) return zk_conn def stopZKConnection(zk_conn):