On Wed, 14 Nov 2007, Bill Janssen wrote:

If you meant to ask if there was another API to attach _another_ thread
to the VM from a given thread, the answer seems to be 'no'.

That's what I was asking.  It means I have to subclass
threading.Thread and add a before-method for run() (to make sure all
my threads are Lucene-capable).  If I could call it from a different
Python thread, I could call it from the thread which creates the new
thread, before I call start() on the new thread.

Yes, this is how I did it in Chandler:

class RepositoryThread(threading.Thread):

    def run(self):

        from lucene import getVMEnv
        getVMEnv().attachCurrentThread()
        super(RepositoryThread, self).run()

Another way to do it without subclassing threading.Thread, is to pass in a callable instance with the target keyword that calls attachCurrentThread()
in its __call__ method.

Andi..

_______________________________________________
pylucene-dev mailing list
[email protected]
http://lists.osafoundation.org/mailman/listinfo/pylucene-dev

Reply via email to