Aric's suggestion seems to have done the trick. I just added "from web.wsgiserver import WorkerThread" and then did exactly as the code snippet that Aric sent below.
- Neha On Mon, Jun 15, 2009 at 3:27 PM, Aric Coady <aric.co...@gmail.com> wrote: > 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. > >