Commits

coady committed bedaad0

Cleanup of unused references and reader closing.

Comments (0)

Files changed (6)

examples/server.py

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

lupyne/engine/documents.py

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

lupyne/engine/indexers.py

 
 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)
         self.shared.update(shared)
         shared.clear()
     :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.
         

lupyne/engine/spatial/__init__.py

 """
 
 import itertools
-import lucene
 from .globalmaptiles import GlobalMercator
 from ..queries import Query
 from ..documents import NumericField
  * 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
 import os
 import tempfile, shutil
 import itertools
-import collections
 import warnings
 import datetime
 import math
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.