The lucene module wrapper takes care of the initialization and threading pitfalls in the JCC API. It automatically initializes the VM when the first object is retrieved from the facade module. It also attaches the current Python thread to the JNI VM environment when it hasn’t been attached before.
The wrapper also solves the problem with JVM installing its own signal handlers. By default the JVM overwrites Python’s signal handlers in initVM(), thus causing some hard to debug problems. For example SIGINT is no longer translated into a KeyboradInterrupt exception. The wrapper code restores all signal handlers to its former state. Only JVM’s SIGSEGV handler is left in place because it logs and prints useful information when the JVM segfaults.
The classpath argument is optional. When no classpath is set, smc.lucene automatically adds classpath=lucene.CLASSPATH for you.
Replace code like:
import lucene lucene.initVM(classpath=lucene.CLASSPATH, vmwargs='...') def query_lucene(...): lucene.attachCurrentThread() query = lucene.BooleanQuery() ...
from smc.lucene import lucene lucene.set_initargs(vmargs='...') def query_lucene(...): query = lucene.BooleanQuery()
Lucene is automatically initialized when the BooleanQuery attribute is retrieved from the facade module. If PyLucene was already initialized the facade module makes sure that the current thread is attached.
You must not assign Lucene attributes to objects which a shared across threads. If you have to share an object across threads you must call lucene.attach() before you can use an object.
from smc.lucene import lucene as lucene_wrapper from lucene import BooleanQuery def query_lucene(...): lucene_wrapper.attach() query = BooleanQuery()
The attach method either initializes lucene or or attaches the current thread.
Copyright (C) 2008 semantics GmbH. All Rights Reserved.:
semantics Kommunikationsmanagement GmbH Viktoriaallee 45 D-52066 Aachen Germany Tel.: +49 241 89 49 89 29 eMail: info(at)semantics.de http://www.semantics.de/
TODO: Figure out how to actually get changelog content.
Changelog content for this version goes here.