简体   繁体   中英

Closing connections to an elasticsearch cluster using elasticsearch-py

I'm trying to close a connection to my elasticsearch cluster in my application code using elasticsearch-py.

Currently, I'm using:

es = Elasticsearch()
es.close()

But, I'm getting the error:

Traceback (most recent call last):
  File "tmp.py", line 45, in <module>
    es.close()
AttributeError: 'Elasticsearch' object has no attribute 'close'

I haven't seen any close methods in the documentation either:

https://elasticsearch-py.readthedocs.io/en/master/api.html

Any help would be greatly appreciated! Thanks in advance :)

You can close the transport with Transport.close :

es = Elasticsearch()
es.transport.close()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM