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') logger.out('Connection to Zookeeper lost; retrying', state='w')
while True: while True:
time.sleep(0.5)
_zk_conn = kazoo.client.KazooClient(hosts=config['coordinators']) _zk_conn = kazoo.client.KazooClient(hosts=config['coordinators'])
try: try:
_zk_conn.start() _zk_conn.start()
except:
del _zk_conn
continue
zk_conn = _zk_conn zk_conn = _zk_conn
break break
except:
time.sleep(1)
zk_conn.add_listener(zk_listener) zk_conn.add_listener(zk_listener)
############################################################################### ###############################################################################