Hello,

I have a very simple webserver that I set up using web.py. See the simplest
example here:
http://webpy.org/cookbook/helloworld

The only change that I have above is that I also have a /search url that is
handled using "class search"  which just searches an index and prints out
the hits. The code for that is also taken from pylucene tutorial:

*class search:
  def GET(self, urlParams=None):
    lucene.initVM(lucene.CLASSPATH)   # Where should this be called, perhaps
not on every request?

      if not (os.path.exists(indexDir) and os.path.isdir(indexDir)):
        return "Invalid Path to Index"

    # Second argument being false indicates that we want to open an existing
index
    # and not construct a new one.
    fsDir = FSDirectory.getDirectory(indexDir, False)
    searcher = IndexSearcher(fsDir)

    # Switch parsing to use AND, so use an instance of QueryParser rather
than
    # the static parse method.
    parser = QueryParser("contents", StandardAnalyzer())
    query = parser.parse("some query")
    hits = searcher.search(query)*

The problem am having is that when I send a few requests one after the other
then the server crashes. I tried to put initVM() right after import lucene
statement at the top of the program but the crash still happens. I also read
this post:
http://lists.osafoundation.org/pipermail/pylucene-dev/2008-April/002634.html.<http://lists.osafoundation.org/pipermail/pylucene-dev/2008-April/002634.html>
The problem seems familiar to mine, however, am not sure where should I put
initVM(). Should I also be calling env.attachCurrentThread() somewhere?

I am very new to pylucene, any help would be great.

Thanks!
Neha

Reply via email to