diff --git a/kibana/connector.py b/kibana/connector.py index 840e7dc69..7f79661cd 100644 --- a/kibana/connector.py +++ b/kibana/connector.py @@ -4,14 +4,15 @@ # 2.0. """Wrapper around requests.Session for HTTP requests to Kibana.""" -import json -import threading +import atexit import base64 +import json import sys +import threading import uuid -from elasticsearch import Elasticsearch import requests +from elasticsearch import Elasticsearch _context = threading.local() @@ -57,8 +58,10 @@ class Kibana(object): self.elasticsearch = elasticsearch if not verify: - from requests.packages.urllib3.exceptions import InsecureRequestWarning + from requests.packages.urllib3.exceptions import \ + InsecureRequestWarning requests.packages.urllib3.disable_warnings(InsecureRequestWarning) + atexit.register(self.__close) @property def version(self): @@ -179,7 +182,7 @@ class Kibana(object): self.session = requests.Session() self.elasticsearch = None - def __del__(self): + def __close(self): if self.authenticated: self.logout()