@@ -43,6 +43,9 @@ class Client(object):
4343 _comparison_conditions = set (('prevValue' , 'prevIndex' , 'prevExist' ))
4444 _read_options = set (('recursive' , 'wait' , 'waitIndex' , 'sorted' , 'quorum' ))
4545 _del_conditions = set (('prevValue' , 'prevIndex' ))
46+
47+ http = None
48+
4649 def __init__ (
4750 self ,
4851 host = '127.0.0.1' ,
@@ -199,6 +202,11 @@ def _discover(self, domain):
199202 raise ValueError ("The SRV record is present but no host were found" )
200203 return tuple (hosts )
201204
205+ def __del__ (self ):
206+ """Clean up open connections"""
207+ if self .http is not None :
208+ self .http .clear ()
209+
202210 @property
203211 def base_uri (self ):
204212 """URI used by the client to connect to etcd."""
@@ -783,7 +791,7 @@ def api_execute(self, path, method, params=None, timeout=None):
783791 else :
784792 raise etcd .EtcdException (
785793 'HTTP method {} not supported' .format (method ))
786-
794+
787795 # Check the cluster ID hasn't changed under us. We use
788796 # preload_content=False above so we can read the headers
789797 # before we wait for the content of a watch.
@@ -823,7 +831,7 @@ def api_execute(self, path, method, params=None, timeout=None):
823831 except :
824832 _log .exception ("Unexpected request failure, re-raising." )
825833 raise
826-
834+
827835 if some_request_failed :
828836 if not self ._use_proxies :
829837 # The cluster may have changed since last invocation
0 commit comments