[pylucene-dev] detachCurrentThread crash

Andi Vajda vajda at osafoundation.org
Mon Jan 14 22:26:06 PST 2008

On Tue, 15 Jan 2008, anurag uniyal wrote:

> So it seems detachCurrentThread can be more harmful then beneficial.
> because crash may occur on creating any lucene object
> e.g. If I use doc = lucene.Document() in a thread without doc = None

Yes, it needs care. You cannot call any Java API once the thread has been 

> And it may not always be possible to clean every object e.g. 
> if some exception is raised or some other function is called which 
> communicates error conditions via Exceptions. e.g. see attached code.

Yep. It's delicate.

> I think I am pretty much stuck here and will have to abondon multiple 
> threads :(

Clearly. At least, given the way you're using them. Use only one thread 
and re-use it instead of creating hundreds of them. Especially since you're 
not using them concurrently (at least in the example code you submitted). If 
you use just one thread and feed it documents to index via a queue and 
notify(), you should get the same effect.


More information about the pylucene-dev mailing list