def _publish(self):
"""
Start coroutine for publish.
:return:
"""
for retry in range(constant.ETCD_RECONNECT_MAX_RETRY_INIT):
try:
co = gevent.spawn(self._publish_handler)
co.join(constant.ETCD_CONNECT_TIMEOUT)
e = co.exception
if e: # if _publish_handler raise some exception, reraise it.
raise e
else:
co.kill()
except (etcd.EtcdConnectionFailed, gevent.Timeout):
log.info('Connect to etcd failed, Retry(%d)...', retry)
gevent.sleep(constant.ETCD_RECONNECT_INTERVAL)
else:
log.info('Publish OK.')
break
else: # publish failed
raise err.OctpEtcdConnectError('Max attempts exceeded.')
评论列表
文章目录