lucene-pylucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aric Coady <aric.co...@gmail.com>
Subject Re: initVM() crash and web.py
Date Mon, 15 Jun 2009 19:27:09 GMT
On Jun 15, 2009, at 12:12 PM, Neha Gupta wrote:
> The problem am having is that when I send a few requests one after  
> the other
> then the server crashes. I tried to put initVM() right after import  
> lucene
> statement at the top of the program but the crash still happens. I  
> also read
> this post:
> http://lists.osafoundation.org/pipermail/pylucene-dev/2008-April/002634.html 
> .<http://lists.osafoundation.org/pipermail/pylucene-dev/2008-April/002634.html 
> >
> The problem seems familiar to mine, however, am not sure where  
> should I put
> initVM(). Should I also be calling env.attachCurrentThread()  
> somewhere?

initVM must be called exactly once, so at the top of the program is a  
fine place for it.  attachCurrentThread must be called at least once  
per thread.  It is idempotent (and fast), so you can put it at the top  
of your request handler.

I prefer putting it in the threading code anyway, instead of  
cluttering the app.  My lupyne project has an example of that:  look  
for WorkerThread in http://code.google.com/p/lupyne/source/browse/trunk/lupyne/server.py 
.  LuPyne uses cherrypy, and web.py uses cherrypy's wsgiserver, so the  
code will translate.


Mime
View raw message