def get_client():
global client
if client is not None:
return client
client = Elasticsearch([os.environ.get('TEST_ES_SERVER', {})], timeout=300)
# wait for yellow status
for _ in range(100):
time.sleep(.1)
try:
client.cluster.health(wait_for_status='yellow')
return client
except ConnectionError:
continue
else:
# timeout
raise SkipTest("Elasticsearch failed to start.")
评论列表
文章目录