You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pylucene-dev@lucene.apache.org by Darren Govoni <da...@ontrenet.com> on 2010/07/16 18:48:40 UTC

attach thread hangs

Hi,
  I have a situation where I have multiple (4) python objects that use
pylucene and initVM's and attach to their own threads.
It works fine for a bit, but eventually calls to
vm.attachCurrentThread()  hangs and never returns across those objects -
each in a separate thread. I only call getVMEnv() once in each objects
init.

I guess I'd like to know if this is something I'm doing wrong or can
fix?

I'm on the latest build (but this problem occurred before updating)

thanks,
Darren

Re: Building a custom Tokenizer

Posted by Martin <ma...@webscio.net>.
Hey,

Thanks for the tips. I was pointed towards the KeywordTokenizer by the 
java people which returns the full content as one content (not a very 
intuitive name in my opinion, but anyway). I might still need to extend 
this to do some customizations, so I'll look into the PythonAnalyzer 
samples.

Thanks again,
Martin
>
> On Jul 17, 2010, at 22:30, Andi Vajda <va...@apache.org> wrote:
>
>>
>> On Jul 17, 2010, at 22:23, Martin <ma...@webscio.net> wrote:
>>
>>> Hi there,
>>>
>>> I'm trying to extend the PythonTokenizer class to build my own 
>>> custom tokenizer, but seem to get stuck pretty much soon after that. 
>>> I know that I'm supposed to extend the incrementToken() method, but 
>>> what exactly am I dealing with in there and what should it return? 
>>> My goal is to construct a tokenizer that returns pretty large 
>>> tokens, maybe sentences or even the whole content. The reason I need 
>>> this is that the NGramTokenFilter needs a TokenStream to run on, but 
>>> any other tokenizer removes whitespaces from the text.. and I need 
>>> ngrams that span over spaces :(
>>>
>>> Thanks in advance for any hints!
>>
>> Check out the Java Lucene javadocs and ask again on 
>> java-user@lucene.apache.org where many more lucene expert users hang 
>> out. Subscribe first by sending mail to java-user-subscribe and 
>> following the instructions in the response.
>
> I forgot to mention that there a number of PyLucene tests and samples 
> doing this by extending PythonAnalyzer. Look for these under the tests 
> and sampled/LuceneInAction directories.
>
> Andi..
>
>>
>> Andi..
>>
>>>
>>> Regards,
>>> Martin
>
>


Re: Building a custom Tokenizer

Posted by Andi Vajda <va...@apache.org>.
On Jul 17, 2010, at 22:30, Andi Vajda <va...@apache.org> wrote:

>
> On Jul 17, 2010, at 22:23, Martin <ma...@webscio.net> wrote:
>
>> Hi there,
>>
>> I'm trying to extend the PythonTokenizer class to build my own  
>> custom tokenizer, but seem to get stuck pretty much soon after  
>> that. I know that I'm supposed to extend the incrementToken()  
>> method, but what exactly am I dealing with in there and what should  
>> it return? My goal is to construct a tokenizer that returns pretty  
>> large tokens, maybe sentences or even the whole content. The reason  
>> I need this is that the NGramTokenFilter needs a TokenStream to run  
>> on, but any other tokenizer removes whitespaces from the text.. and  
>> I need ngrams that span over spaces :(
>>
>> Thanks in advance for any hints!
>
> Check out the Java Lucene javadocs and ask again on java-user@lucene.apache.org 
>  where many more lucene expert users hang out. Subscribe first by  
> sending mail to java-user-subscribe and following the instructions  
> in the response.

I forgot to mention that there a number of PyLucene tests and samples  
doing this by extending PythonAnalyzer. Look for these under the tests  
and sampled/LuceneInAction directories.

Andi..

>
> Andi..
>
>>
>> Regards,
>> Martin

Re: Building a custom Tokenizer

Posted by Andi Vajda <va...@apache.org>.
On Jul 17, 2010, at 22:23, Martin <ma...@webscio.net> wrote:

> Hi there,
>
> I'm trying to extend the PythonTokenizer class to build my own  
> custom tokenizer, but seem to get stuck pretty much soon after that.  
> I know that I'm supposed to extend the incrementToken() method, but  
> what exactly am I dealing with in there and what should it return?  
> My goal is to construct a tokenizer that returns pretty large  
> tokens, maybe sentences or even the whole content. The reason I need  
> this is that the NGramTokenFilter needs a TokenStream to run on, but  
> any other tokenizer removes whitespaces from the text.. and I need  
> ngrams that span over spaces :(
>
> Thanks in advance for any hints!

Check out the Java Lucene javadocs and ask again on java-user@lucene.apache.org 
  where many more lucene expert users hang out. Subscribe first by  
sending mail to java-user-subscribe and following the instructions in  
the response.

Andi..

>
> Regards,
> Martin

Building a custom Tokenizer

Posted by Martin <ma...@webscio.net>.
Hi there,

I'm trying to extend the PythonTokenizer class to build my own custom 
tokenizer, but seem to get stuck pretty much soon after that. I know 
that I'm supposed to extend the incrementToken() method, but what 
exactly am I dealing with in there and what should it return? My goal is 
to construct a tokenizer that returns pretty large tokens, maybe 
sentences or even the whole content. The reason I need this is that the 
NGramTokenFilter needs a TokenStream to run on, but any other tokenizer 
removes whitespaces from the text.. and I need ngrams that span over 
spaces :(

Thanks in advance for any hints!

Regards,
Martin

Re: [pylucene-dev] Downcast of TermFreqVector to TermPositionVector

Posted by Martin <ma...@webscio.net>.
Yea, it was a message from 2007, couldn't find any other mention of 
TermPositionVector anywhere else so..

Thanks a lot for the tip, works like a charm!
>
> On Jul 17, 2010, at 15:04, Martin <ma...@webscio.net> wrote:
>
>> Hi,
>>
>> this seems to be missing in the 3.0.2. release, or at least not 
>> working - I'm getting AttributeError: 'TermFreqVector' object has no 
>> attribute 'toTermPositionVector'. Has it been 
>> accidentally/intentionally removed in the last couple of years and/or 
>> is there an alternative to getting a TermPositionVector?
>
> You must be refering to some very old release there. Casting is done 
> via the cast_() method:
> TermPositionVector.cast_(tfv)
>
> Andi..
>
>>
>> Thanks for your help!
>>
>> Martin
>>
>>
>> I checked-in your patch into svn trunk revision 337.
>>
>> Thank you for your contribution !
>>
>> Andi..
>
>


Re: [pylucene-dev] Downcast of TermFreqVector to TermPositionVector

Posted by Andi Vajda <va...@apache.org>.
On Jul 17, 2010, at 15:04, Martin <ma...@webscio.net> wrote:

> Hi,
>
> this seems to be missing in the 3.0.2. release, or at least not  
> working - I'm getting AttributeError: 'TermFreqVector' object has no  
> attribute 'toTermPositionVector'. Has it been accidentally/ 
> intentionally removed in the last couple of years and/or is there an  
> alternative to getting a TermPositionVector?

You must be refering to some very old release there. Casting is done  
via the cast_() method:
TermPositionVector.cast_(tfv)

Andi..

>
> Thanks for your help!
>
> Martin
>
>
> I checked-in your patch into svn trunk revision 337.
>
> Thank you for your contribution !
>
> Andi..

Re: [pylucene-dev] Downcast of TermFreqVector to TermPositionVector

Posted by Martin <ma...@webscio.net>.
Hi,

this seems to be missing in the 3.0.2. release, or at least not working 
- I'm getting AttributeError: 'TermFreqVector' object has no attribute 
'toTermPositionVector'. Has it been accidentally/intentionally removed 
in the last couple of years and/or is there an alternative to getting a 
TermPositionVector?

Thanks for your help!

Martin


I checked-in your patch into svn trunk revision 337.

Thank you for your contribution !

Andi..


Re: attach thread hangs

Posted by Andi Vajda <va...@apache.org>.
On Sat, 17 Jul 2010, Darren Govoni wrote:

> I wonder why attach locks under processes but not threads though? Is it jcc
> related or JVM?

If you're running things in sub-processes, I don't think it makes any sense 
to call attachCurrentThread() into the parent JVM at all, nor do I expect 
calls into the parent JVM to work.

If, on the other hand, you create a new JVM in each sub-process (something I 
don't expect to work well either, if at all), then these sub-processes are 
the 'main' thread for the JVM and thus don't need attachCurrentThread() 
at all.

> There are advantages to using heavy-weight processes over threads though,
> one being tighter integration with SMP and multicore CPUs under linux.

Of course, but then don't think of them as threads but rather as processes 
and start a JVM for each and every one of them, something pretty heavy.

Andi..

> 
> On Sat, 2010-07-17 at 03:16 -0700, Andi Vajda wrote:
> 
> On Fri, 16 Jul 2010, Darren Govoni wrote:
> 
> > I corrected some things with my threads, so I'm sure they are being reused
> > now.
> > 
> > But I was using python's multiprocessing module and my worker threads were
> > actually processes.
> > This is where I saw the lock up after a period of time.
> 
> Ah ha, so nothing to do with attachCurrentThread() after all.
> 
> > I switch my workers to just plain threads and I don't get the lockup.
> > 
> > Not sure what it means though.
> 
> I tried to do something similar, use Python's multiprocessing from a 
> jcc-embedded Python VM inside a Tomcat Java VM and also had lock-up 
> problems. I eventually gave up and just used threads, not as GIL-happy but 
> good enough and without any lock-ups.
> 
> Andi..
> 
> > 
> > Darren
> > 
> > On Fri, 2010-07-16 at 16:29 -0700, Andi Vajda wrote:
> > 
> > On Sat, 17 Jul 2010, Andi Vajda wrote:
> > 
> > >
> > > On Jul 16, 2010, at 23:14, Darren Govoni <da...@ontrenet.com> wrote:
> > >
> > >> btw. I have a timer thread that watches a message queue and then
> > >> performs lucene lookups, so every time
> > >> that timer thread invokes my object, its a new thread.
> > >
> > > Don't do that. Instead, pool your threads and reuse them.
> > 
> > Another thing you could do is create your threads by instantiating Java's 
> > java.lang.Thread class instead of Python's. No attachCurrentThread() 
> > call then is needed since the OS thread is created by the JVM.
> > 
> > Andi..
> > 
> > >
> > > Andi..
> > >
> > >> 
> > >> I tried calling detachCurrentThread in the object's method after the
> > >> attach and the detach threw a java compiler exception right away.
> > >> 
> > >> #
> > >> # A fatal error has been detected by the Java Runtime Environment:
> > >> #
> > >> #  SIGSEGV (0xb) at pc=0x00522e51, pid=23974, tid=3075853168
> > >> #
> > >> # JRE version: 6.0_20-b02
> > >> # Java VM: Java HotSpot(TM) Client VM (16.3-b01 mixed mode, sharing
> > >> linux-x86 )
> > >> # Problematic frame:
> > >> # C  [libjcc.so+0x9e51]  _ZN6JCCEnv15deleteGlobalRefEP8_jobjecti+0x171
> > >> #
> > >> # An error report file with more information is saved as:
> > >> # 
> > >> /home/darren/Gridwave/product/trunk/symphony/server/software/hs_err_pid
> 23
> > 974.log
> > >> #
> > >> # If you would like to submit a bug report, please visit:
> > >> #   http://java.sun.com/webapps/bugreport/crash.jsp
> > >> 
> > >> It seems I can't use the pylucene object as a singleton because new
> > >> instances are created by new threads that need to be attached.
> > >> 
> > >> Tricky this is.
> > >> 
> > >> On Fri, 2010-07-16 at 16:59 -0400, Darren Govoni wrote:
> > >> 
> > >>> Ok, thanks Andi.
> > >>> 
> > >>> On Fri, 2010-07-16 at 20:04 +0200, Andi Vajda wrote:
> > >>> 
> > >>>> On Jul 16, 2010, at 18:48, Darren Govoni <da...@ontrenet.com> wrote:
> > >>>> 
> > >>>>> Hi,
> > >>>>> I have a situation where I have multiple (4) python objects that use
> > >>>>> pylucene and initVM's and attach to their own threads.
> > >>>>> It works fine for a bit, but eventually calls to
> > >>>>> vm.attachCurrentThread()  hangs and never returns across those
> > >>>>> objects -
> > >>>>> each in a separate thread. I only call getVMEnv() once in each objec
> ts
> > >>>>> init.
> > >>>>> 
> > >>>>> I guess I'd like to know if this is something I'm doing wrong or can
> > >>>>> fix?
> > >>>>> 
> > >>>>> I'm on the latest build (but this problem occurred before updating)
> > >>>> 
> > >>>> Try calling attachCurrentThread() only once per thread and reusing
> > >>>> these threads instead of creating and throwing them away. If you stil
> l
> > >>>> must dispose of threads, try calling detachCurrentThread() but it's
> > >>>> not guaranteed to work safely if anything in Python is still holding
> > >>>> any java object references.
> > >>>> 
> > >>>> Andi..
> > >>>> 
> > >>>>> 
> > >>>>> thanks,
> > >>>>> Darren
> > >>> 
> > >>> 
> > >> 
> > >
> > 
> > 
> > 
> >
> 
> 
> 
>

Re: attach thread hangs

Posted by Andi Vajda <va...@apache.org>.
On Fri, 16 Jul 2010, Darren Govoni wrote:

> I corrected some things with my threads, so I'm sure they are being reused
> now.
> 
> But I was using python's multiprocessing module and my worker threads were
> actually processes.
> This is where I saw the lock up after a period of time.

Ah ha, so nothing to do with attachCurrentThread() after all.

> I switch my workers to just plain threads and I don't get the lockup.
> 
> Not sure what it means though.

I tried to do something similar, use Python's multiprocessing from a 
jcc-embedded Python VM inside a Tomcat Java VM and also had lock-up 
problems. I eventually gave up and just used threads, not as GIL-happy but 
good enough and without any lock-ups.

Andi..

> 
> Darren
> 
> On Fri, 2010-07-16 at 16:29 -0700, Andi Vajda wrote:
> 
> On Sat, 17 Jul 2010, Andi Vajda wrote:
> 
> >
> > On Jul 16, 2010, at 23:14, Darren Govoni <da...@ontrenet.com> wrote:
> >
> >> btw. I have a timer thread that watches a message queue and then
> >> performs lucene lookups, so every time
> >> that timer thread invokes my object, its a new thread.
> >
> > Don't do that. Instead, pool your threads and reuse them.
> 
> Another thing you could do is create your threads by instantiating Java's 
> java.lang.Thread class instead of Python's. No attachCurrentThread() 
> call then is needed since the OS thread is created by the JVM.
> 
> Andi..
> 
> >
> > Andi..
> >
> >> 
> >> I tried calling detachCurrentThread in the object's method after the
> >> attach and the detach threw a java compiler exception right away.
> >> 
> >> #
> >> # A fatal error has been detected by the Java Runtime Environment:
> >> #
> >> #  SIGSEGV (0xb) at pc=0x00522e51, pid=23974, tid=3075853168
> >> #
> >> # JRE version: 6.0_20-b02
> >> # Java VM: Java HotSpot(TM) Client VM (16.3-b01 mixed mode, sharing
> >> linux-x86 )
> >> # Problematic frame:
> >> # C  [libjcc.so+0x9e51]  _ZN6JCCEnv15deleteGlobalRefEP8_jobjecti+0x171
> >> #
> >> # An error report file with more information is saved as:
> >> # 
> >> /home/darren/Gridwave/product/trunk/symphony/server/software/hs_err_pid23
> 974.log
> >> #
> >> # If you would like to submit a bug report, please visit:
> >> #   http://java.sun.com/webapps/bugreport/crash.jsp
> >> 
> >> It seems I can't use the pylucene object as a singleton because new
> >> instances are created by new threads that need to be attached.
> >> 
> >> Tricky this is.
> >> 
> >> On Fri, 2010-07-16 at 16:59 -0400, Darren Govoni wrote:
> >> 
> >>> Ok, thanks Andi.
> >>> 
> >>> On Fri, 2010-07-16 at 20:04 +0200, Andi Vajda wrote:
> >>> 
> >>>> On Jul 16, 2010, at 18:48, Darren Govoni <da...@ontrenet.com> wrote:
> >>>> 
> >>>>> Hi,
> >>>>> I have a situation where I have multiple (4) python objects that use
> >>>>> pylucene and initVM's and attach to their own threads.
> >>>>> It works fine for a bit, but eventually calls to
> >>>>> vm.attachCurrentThread()  hangs and never returns across those
> >>>>> objects -
> >>>>> each in a separate thread. I only call getVMEnv() once in each objects
> >>>>> init.
> >>>>> 
> >>>>> I guess I'd like to know if this is something I'm doing wrong or can
> >>>>> fix?
> >>>>> 
> >>>>> I'm on the latest build (but this problem occurred before updating)
> >>>> 
> >>>> Try calling attachCurrentThread() only once per thread and reusing
> >>>> these threads instead of creating and throwing them away. If you still
> >>>> must dispose of threads, try calling detachCurrentThread() but it's
> >>>> not guaranteed to work safely if anything in Python is still holding
> >>>> any java object references.
> >>>> 
> >>>> Andi..
> >>>> 
> >>>>> 
> >>>>> thanks,
> >>>>> Darren
> >>> 
> >>> 
> >> 
> >
> 
> 
> 
>

Re: attach thread hangs

Posted by Andi Vajda <va...@apache.org>.
On Sat, 17 Jul 2010, Andi Vajda wrote:

>
> On Jul 16, 2010, at 23:14, Darren Govoni <da...@ontrenet.com> wrote:
>
>> btw. I have a timer thread that watches a message queue and then
>> performs lucene lookups, so every time
>> that timer thread invokes my object, its a new thread.
>
> Don't do that. Instead, pool your threads and reuse them.

Another thing you could do is create your threads by instantiating Java's 
java.lang.Thread class instead of Python's. No attachCurrentThread() 
call then is needed since the OS thread is created by the JVM.

Andi..

>
> Andi..
>
>> 
>> I tried calling detachCurrentThread in the object's method after the
>> attach and the detach threw a java compiler exception right away.
>> 
>> #
>> # A fatal error has been detected by the Java Runtime Environment:
>> #
>> #  SIGSEGV (0xb) at pc=0x00522e51, pid=23974, tid=3075853168
>> #
>> # JRE version: 6.0_20-b02
>> # Java VM: Java HotSpot(TM) Client VM (16.3-b01 mixed mode, sharing
>> linux-x86 )
>> # Problematic frame:
>> # C  [libjcc.so+0x9e51]  _ZN6JCCEnv15deleteGlobalRefEP8_jobjecti+0x171
>> #
>> # An error report file with more information is saved as:
>> # 
>> /home/darren/Gridwave/product/trunk/symphony/server/software/hs_err_pid23974.log
>> #
>> # If you would like to submit a bug report, please visit:
>> #   http://java.sun.com/webapps/bugreport/crash.jsp
>> 
>> It seems I can't use the pylucene object as a singleton because new
>> instances are created by new threads that need to be attached.
>> 
>> Tricky this is.
>> 
>> On Fri, 2010-07-16 at 16:59 -0400, Darren Govoni wrote:
>> 
>>> Ok, thanks Andi.
>>> 
>>> On Fri, 2010-07-16 at 20:04 +0200, Andi Vajda wrote:
>>> 
>>>> On Jul 16, 2010, at 18:48, Darren Govoni <da...@ontrenet.com> wrote:
>>>> 
>>>>> Hi,
>>>>> I have a situation where I have multiple (4) python objects that use
>>>>> pylucene and initVM's and attach to their own threads.
>>>>> It works fine for a bit, but eventually calls to
>>>>> vm.attachCurrentThread()  hangs and never returns across those
>>>>> objects -
>>>>> each in a separate thread. I only call getVMEnv() once in each objects
>>>>> init.
>>>>> 
>>>>> I guess I'd like to know if this is something I'm doing wrong or can
>>>>> fix?
>>>>> 
>>>>> I'm on the latest build (but this problem occurred before updating)
>>>> 
>>>> Try calling attachCurrentThread() only once per thread and reusing
>>>> these threads instead of creating and throwing them away. If you still
>>>> must dispose of threads, try calling detachCurrentThread() but it's
>>>> not guaranteed to work safely if anything in Python is still holding
>>>> any java object references.
>>>> 
>>>> Andi..
>>>> 
>>>>> 
>>>>> thanks,
>>>>> Darren
>>> 
>>> 
>> 
>

Re: attach thread hangs

Posted by Andi Vajda <va...@apache.org>.
On Jul 16, 2010, at 23:14, Darren Govoni <da...@ontrenet.com> wrote:

> btw. I have a timer thread that watches a message queue and then
> performs lucene lookups, so every time
> that timer thread invokes my object, its a new thread.

Don't do that. Instead, pool your threads and reuse them.

Andi..

>
> I tried calling detachCurrentThread in the object's method after the
> attach and the detach threw a java compiler exception right away.
>
> #
> # A fatal error has been detected by the Java Runtime Environment:
> #
> #  SIGSEGV (0xb) at pc=0x00522e51, pid=23974, tid=3075853168
> #
> # JRE version: 6.0_20-b02
> # Java VM: Java HotSpot(TM) Client VM (16.3-b01 mixed mode, sharing
> linux-x86 )
> # Problematic frame:
> # C  [libjcc.so+0x9e51]  _ZN6JCCEnv15deleteGlobalRefEP8_jobjecti+0x171
> #
> # An error report file with more information is saved as:
> # /home/darren/Gridwave/product/trunk/symphony/server/software/ 
> hs_err_pid23974.log
> #
> # If you would like to submit a bug report, please visit:
> #   http://java.sun.com/webapps/bugreport/crash.jsp
>
> It seems I can't use the pylucene object as a singleton because new
> instances are created by new threads that need to be attached.
>
> Tricky this is.
>
> On Fri, 2010-07-16 at 16:59 -0400, Darren Govoni wrote:
>
>> Ok, thanks Andi.
>>
>> On Fri, 2010-07-16 at 20:04 +0200, Andi Vajda wrote:
>>
>>> On Jul 16, 2010, at 18:48, Darren Govoni <da...@ontrenet.com>  
>>> wrote:
>>>
>>>> Hi,
>>>> I have a situation where I have multiple (4) python objects that  
>>>> use
>>>> pylucene and initVM's and attach to their own threads.
>>>> It works fine for a bit, but eventually calls to
>>>> vm.attachCurrentThread()  hangs and never returns across those
>>>> objects -
>>>> each in a separate thread. I only call getVMEnv() once in each  
>>>> objects
>>>> init.
>>>>
>>>> I guess I'd like to know if this is something I'm doing wrong or  
>>>> can
>>>> fix?
>>>>
>>>> I'm on the latest build (but this problem occurred before updating)
>>>
>>> Try calling attachCurrentThread() only once per thread and reusing
>>> these threads instead of creating and throwing them away. If you  
>>> still
>>> must dispose of threads, try calling detachCurrentThread() but it's
>>> not guaranteed to work safely if anything in Python is still holding
>>> any java object references.
>>>
>>> Andi..
>>>
>>>>
>>>> thanks,
>>>> Darren
>>
>>
>
>

Re: attach thread hangs

Posted by Darren Govoni <da...@ontrenet.com>.
btw. I have a timer thread that watches a message queue and then
performs lucene lookups, so every time
that timer thread invokes my object, its a new thread.

I tried calling detachCurrentThread in the object's method after the
attach and the detach threw a java compiler exception right away.

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00522e51, pid=23974, tid=3075853168
#
# JRE version: 6.0_20-b02
# Java VM: Java HotSpot(TM) Client VM (16.3-b01 mixed mode, sharing
linux-x86 )
# Problematic frame:
# C  [libjcc.so+0x9e51]  _ZN6JCCEnv15deleteGlobalRefEP8_jobjecti+0x171
#
# An error report file with more information is saved as:
# /home/darren/Gridwave/product/trunk/symphony/server/software/hs_err_pid23974.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp

It seems I can't use the pylucene object as a singleton because new
instances are created by new threads that need to be attached.

Tricky this is.

On Fri, 2010-07-16 at 16:59 -0400, Darren Govoni wrote:

> Ok, thanks Andi.
> 
> On Fri, 2010-07-16 at 20:04 +0200, Andi Vajda wrote:
> 
> > On Jul 16, 2010, at 18:48, Darren Govoni <da...@ontrenet.com> wrote:
> > 
> > > Hi,
> > >  I have a situation where I have multiple (4) python objects that use
> > > pylucene and initVM's and attach to their own threads.
> > > It works fine for a bit, but eventually calls to
> > > vm.attachCurrentThread()  hangs and never returns across those  
> > > objects -
> > > each in a separate thread. I only call getVMEnv() once in each objects
> > > init.
> > >
> > > I guess I'd like to know if this is something I'm doing wrong or can
> > > fix?
> > >
> > > I'm on the latest build (but this problem occurred before updating)
> > 
> > Try calling attachCurrentThread() only once per thread and reusing  
> > these threads instead of creating and throwing them away. If you still  
> > must dispose of threads, try calling detachCurrentThread() but it's  
> > not guaranteed to work safely if anything in Python is still holding  
> > any java object references.
> > 
> > Andi..
> > 
> > >
> > > thanks,
> > > Darren
> 
> 



Re: attach thread hangs

Posted by Darren Govoni <da...@ontrenet.com>.
Ok, thanks Andi.

On Fri, 2010-07-16 at 20:04 +0200, Andi Vajda wrote:

> On Jul 16, 2010, at 18:48, Darren Govoni <da...@ontrenet.com> wrote:
> 
> > Hi,
> >  I have a situation where I have multiple (4) python objects that use
> > pylucene and initVM's and attach to their own threads.
> > It works fine for a bit, but eventually calls to
> > vm.attachCurrentThread()  hangs and never returns across those  
> > objects -
> > each in a separate thread. I only call getVMEnv() once in each objects
> > init.
> >
> > I guess I'd like to know if this is something I'm doing wrong or can
> > fix?
> >
> > I'm on the latest build (but this problem occurred before updating)
> 
> Try calling attachCurrentThread() only once per thread and reusing  
> these threads instead of creating and throwing them away. If you still  
> must dispose of threads, try calling detachCurrentThread() but it's  
> not guaranteed to work safely if anything in Python is still holding  
> any java object references.
> 
> Andi..
> 
> >
> > thanks,
> > Darren



Re: attach thread hangs

Posted by Andi Vajda <va...@apache.org>.
On Jul 16, 2010, at 18:48, Darren Govoni <da...@ontrenet.com> wrote:

> Hi,
>  I have a situation where I have multiple (4) python objects that use
> pylucene and initVM's and attach to their own threads.
> It works fine for a bit, but eventually calls to
> vm.attachCurrentThread()  hangs and never returns across those  
> objects -
> each in a separate thread. I only call getVMEnv() once in each objects
> init.
>
> I guess I'd like to know if this is something I'm doing wrong or can
> fix?
>
> I'm on the latest build (but this problem occurred before updating)

Try calling attachCurrentThread() only once per thread and reusing  
these threads instead of creating and throwing them away. If you still  
must dispose of threads, try calling detachCurrentThread() but it's  
not guaranteed to work safely if anything in Python is still holding  
any java object references.

Andi..

>
> thanks,
> Darren