I'm using pylucene in a django based site and I was wondering if anyone knew where the best place to start up the jvm and attach threads would be. I don't want to have to start a new jvm every time someone loads a page, but I was occasionally getting the cryptic "Cannot Import Name" error in django when I was attaching threads at search time.
Is it a mistake to attach the thread in views.py?
Edit: I'm specifically looking for a way to instantiate a single jvm and leave it running so I can just attach threads to it as needed. It takes about two seconds to instantiate the jvm and this is a noticeable delay when searching.