Avoid circular references to make GC's life a bit easier

This commit is contained in:
Honza Kral
2013-08-14 01:42:19 +02:00
parent 56e314f5b0
commit c7cf8011f4
+5 -2
View File
@@ -1,3 +1,5 @@
import weakref
from ..transport import Transport
from ..exceptions import NotFoundError, TransportError
from .indices import IndicesClient
@@ -53,8 +55,9 @@ class Elasticsearch(object):
self.transport = transport_class(_normalize_hosts(hosts), **kwargs)
# namespaced clients for compatibility with API names
self.indices = IndicesClient(self)
self.cluster = ClusterClient(self)
# use weakref to make GC's work a little easier
self.indices = IndicesClient(weakref.proxy(self))
self.cluster = ClusterClient(weakref.proxy(self))
def _bulk_body(self, body):
# if not passed in a string, serialize items and join by newline