def _start(self, err_msg, spawn_monit=False):
if self._is_destroyed:
return
self._client = None
# Increase the session timeout from 10 to 25 seconds.
try:
host_list = self.zk_hosts
client = KazooClient(
hosts=",".join(host_list),
timeout=self._get_session_timeout(),
max_retries=3,
handler=SequentialGeventHandler())
# Increase the start timeout to 20 seconds from 15 seconds.
# Guard this with explicit gevent timeout to protect us from
# some corner cases where starting client failed to respect
# start timeout passed in below.
with gevent.Timeout(seconds=self._get_start_timeout() + 5):
client.start(timeout=self._get_start_timeout())
client.ensure_path("/")
self._last_success_health_check_ts = time.time()
log.info("Successfully started kazoo client.")
self._client = client
except (Exception, gevent.Timeout):
self._sc.increment("errors.zk.client.start.failure",
tags={'host': hostname},
sample_rate=1)
log.exception(err_msg)
finally:
if spawn_monit:
self._monit_greenlet = gevent.spawn(self._monit)
gevent.sleep(0)
评论列表
文章目录