Handle client connection falures gracefully

This commit is contained in:
Joshua Boniface 2019-07-12 00:44:25 -04:00
parent 383bc958fe
commit e765ec7f49
1 changed files with 8 additions and 1 deletions

View File

@ -46,7 +46,14 @@ def validateUUID(dom_uuid):
# #
def startZKConnection(zk_host): def startZKConnection(zk_host):
zk_conn = kazoo.client.KazooClient(hosts=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 return zk_conn
def stopZKConnection(zk_conn): def stopZKConnection(zk_conn):