Improve ZK connection loss handling

This commit is contained in:
Joshua Boniface 2019-07-09 19:14:53 -04:00
parent 47f86475f8
commit 7df200ac44
1 changed files with 8 additions and 3 deletions

View File

@ -468,13 +468,18 @@ def zk_listener(state):
logger.out('Connection to Zookeeper lost; retrying', state='w')
while True:
time.sleep(0.5)
_zk_conn = kazoo.client.KazooClient(hosts=config['coordinators'])
try:
_zk_conn.start()
zk_conn = _zk_conn
break
except:
time.sleep(1)
del _zk_conn
continue
zk_conn = _zk_conn
break
zk_conn.add_listener(zk_listener)
###############################################################################