There seems to be a bug in pylucene where it races if you do not read the value of the attach

try adding a wait in your thread like so

class ThreadSearch(threading.Thread):
    def __init__(self, queue, jvm):
        threading.Thread.__init__(self)
        self.queue = queue
        self.jvm = jvm
    def run(self):
        attached = False
        while not attached:
            if self.jvm.attachCurrentThread() == 0:
                attached = True
        

In my local testing that seemed to cure it

On 29/03/12 10:27, David Mosca wrote:
Unfortunately not. Interestingly enough I had already tried a sleep(1) when 
populating the queue, with no results.


From: Greg Bowyer [mailto:gbow...@fastmail.co.uk]
Sent: 29 March 2012 18:09
To: David Mosca
Cc: java-user@lucene.apache.org
Subject: Re: PyLucene Error Message

Its a bit crap, but can you stick a time.sleep(0.5) just after the attach to 
see if that cures it

On 29/03/2012 09:56, David Mosca wrote:
Yes I am using threads (threading module).

I initialise the JVM like this: jvm = lucene.initVM(initialheap='8G', 
maxheap='8G')

Then I use it as follows:

for i in range(8):
         t = ThreadSearch(queue, jvm)
         t.setDaemon(True)
         t.start()

with ThreadSearch built like this:

class ThreadSearch(threading.Thread):
     def __init__(self, queue, jvm):
         threading.Thread.__init__(self)
         self.queue = queue
         self.jvm = jvm
     def run(self):
         self.jvm.attachCurrentThread()

I have tried lucene.getVMEnv().attachCurrentThread() instead but I still get 
the same error message.

Thanks,

David

From: Greg Bowyer [mailto:gbow...@fastmail.co.uk]
Sent: 29 March 2012 17:30
To: David Mosca
Cc: java-user@lucene.apache.org<mailto:java-user@lucene.apache.org>
Subject: Re: PyLucene Error Message

Wow a VM / hotspot crash, are you using threads ?

If you are make sure you have correctly attached the vm env to each new thread 
*after* you have initialised it on the main thread

This is done with the following
lucene.getVMEnv().attachCurrentThread()

On 29/03/2012 09:10, David Mosca wrote:

I have re-attached the log.



Thanks,



David





-----Original Message-----

From: Greg Bowyer [mailto:gbow...@fastmail.co.uk]

Sent: 29 March 2012 16:55

To: java-user@lucene.apache.org<mailto:java-user@lucene.apache.org>

Subject: Re: PyLucene Error Message



I dont see any attached log, can you attach the log please.



-- Greg

On 29/03/2012 07:35, David Mosca wrote:



Hello,



I am using Lucene version 3.4 through the Python extension (pylucene)

in a multi-threaded script. When I launch the script I sometimes get a

fatal error message (log attached) and sometimes not (I always launch

the same script, exactly in the same way). When I get the error

message I keep launching the script again until the script stops

crashing (it sometimes takes up to 5 or 6 times).



Could you please have a look into this?



Thank you.



*David*







---------------------------------------------------------------------

To unsubscribe, e-mail: 
java-user-unsubscr...@lucene.apache.org<mailto:java-user-unsubscr...@lucene.apache.org>

For additional commands, e-mail: 
java-user-h...@lucene.apache.org<mailto:java-user-h...@lucene.apache.org>







---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org

Reply via email to