Can't get python client wait_for_status to work

I'm using docker-compose to run two services: elasticsearch and a Python indexer. This works:

es = Elasticsearch([elasticsearch_url])
time.sleep(30)
es.indices.delete(index=index_name)

I'm trying to use wait_for_status instead of sleep:

es = Elasticsearch([elasticsearch_url])
es.cluster.health(wait_for_status='yellow', request_timeout=30)
es.indices.delete(index=index_name)

I get (see https://justpaste.it/1i16l):

indexer_1 | Traceback (most recent call last):
indexer_1 | File "indexer.py", line 142, in
indexer_1 | main()
indexer_1 | File "indexer.py", line 127, in main
indexer_1 | es = init_elasticsearch(args.elasticsearch_url, index_name)
indexer_1 | File "indexer.py", line 61, in init_elasticsearch
indexer_1 | es.cluster.health(wait_for_status='yellow', request_timeout=30)
indexer_1 | File "/usr/local/lib/python2.7/site-packages/elasticsearch/client/utils.py", line 76, in _wrapped
indexer_1 | return func(*args, params=params, **kwargs)
indexer_1 | File "/usr/local/lib/python2.7/site-packages/elasticsearch/client/cluster.py", line 33, in health
indexer_1 | 'health', index), params=params)
indexer_1 | File "/usr/local/lib/python2.7/site-packages/elasticsearch/transport.py", line 314, in perform_request
indexer_1 | status, headers_response, data = connection.perform_request(method, url, params, body, headers=headers, ignore=ignore, timeout=timeout)
indexer_1 | File "/usr/local/lib/python2.7/site-packages/elasticsearch/connection/http_urllib3.py", line 158, in perform_request
indexer_1 | raise ConnectionError('N/A', str(e), e)
indexer_1 | elasticsearch.exceptions.ConnectionError: ConnectionError(<urllib3.connection.HTTPConnection object at 0x7f687e347450>: Failed to establish a new connection: [Errno 111] Connection refused) caused by: NewConnectionError(<urllib3.connection.HTTPConnection object at 0x7f687e347450>: Failed to establish a new connection: [Errno 111] Connection refused)
bigquery_indexer_1 exited with code 1

I also tried:

es.cluster.health(wait_for_status='yellow')
es.cluster.health(wait_for_status='yellow', timeout=30)

Ping. (Don't want this to auto-close in a month).

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.