[pylucene-dev] attachCurrentThread from a different thread?
Andi Vajda
vajda at osafoundation.org
Wed Nov 14 13:20:04 PST 2007
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..
More information about the pylucene-dev
mailing list