1. coady
  2. lupyne


coady  committed bedaad0

Cleanup of unused references and reader closing.

  • Participants
  • Parent commits 45dab79
  • Branches default

Comments (0)

Files changed (6)

File examples/server.py

View file
  * http://localhost:8080/search?q=text:right&count=3&facets=year
-import os
 import lucene
 from lupyne import engine, server
 from test import fixture

File lupyne/engine/documents.py

View file
 Wrappers for lucene Fields and Documents.
-from future_builtins import map, zip
+from future_builtins import map
 import datetime, calendar
 import operator
 import collections

File lupyne/engine/indexers.py

View file
 from future_builtins import map, zip
 import os
-import re
 import itertools, operator
 import contextlib
 import abc, collections
     "Manage lifespan of registered objects, similar to contextlib.closing."
     def __del__(self):
         for obj in self:
-            getattr(obj, 'decRef', obj.close)()
+            obj.close()
     def analyzer(self, analyzer, version=None):
         if analyzer is None:
             analyzer = lucene.StandardAnalyzer(version or lucene.Version.values()[-1])
     def __init__(self, directory, analyzer=None):
         self.shared = closing()
         lucene.IndexSearcher.__init__(self, self.shared.reader(directory))
-        self.owned = closing([self.indexReader])
         self.analyzer = self.shared.analyzer(analyzer)
         self.filters, self.sorters, self.spellcheckers = {}, {}, {}
         self.termsfilters, self.groupings = set(), {}
         return self
     def __del__(self):
         if hash(self):
-            self.close()
+            self.decRef()
     def reopen(self, filters=False, sorters=False, spellcheckers=False):
         """Return current `IndexSearcher`_, only creating a new one if necessary.
         Any registered :attr:`termsfilters` are also refreshed.
         shared = closing()
         if not lucene.MultiReader.instance_(reader):
             reader = lucene.MultiReader(list(map(shared.reader, reader)))
-            owned = closing([reader]) # decRef when finished
+            ref = closing([reader])
         IndexSearcher.__init__(self, reader, analyzer)
     :param attrs: additional attributes to set on IndexWriterConfig
     __len__ = lucene.IndexWriter.numDocs
-    __del__ = IndexSearcher.__dict__['__del__']
     parse = IndexSearcher.__dict__['parse']
     def __init__(self, directory=None, mode='a', analyzer=None, version=None, **attrs):
         self.shared = closing()
         config.indexDeletionPolicy = self.policy = lucene.SnapshotDeletionPolicy(config.indexDeletionPolicy)
         lucene.IndexWriter.__init__(self, self.shared.directory(directory), config)
         self.fields = {}
+    def __del__(self):
+        if hash(self):
+            self.close()
     def set(self, name, cls=Field, **params):
         """Assign parameters to field name.

File lupyne/engine/spatial/__init__.py

View file
 import itertools
-import lucene
 from .globalmaptiles import GlobalMercator
 from ..queries import Query
 from ..documents import NumericField

File lupyne/server.py

View file
  * Recommended that the VM ignores keyboard interrupts (-Xrs) for clean server shutdown.
-from future_builtins import filter, map
+from future_builtins import map
 import re
 import time
 import uuid
 import socket, httplib
 import heapq
 import collections
-import itertools, operator
+import itertools
 import os, optparse
 from email.utils import formatdate
 import contextlib

File test/local.py

View file
 import os
 import tempfile, shutil
 import itertools
-import collections
 import warnings
 import datetime
 import math