I'm using mod-wsgi with django, as well as in django I personally use pylucene to complete full text search.
While mod-wsgi is set up to become embedded mode, there's not a problem whatsoever. However when mod-wsgi is set up to become daemon mode, the apache just will get stuck, and also the browser just keep loading but nothing seems.
I Quickly identity the issue to become the jcc.initVM(). Here's my wsgi script:
import os, sys, jcc sys.stderr.write('jcc.initVM\n') jcc.initVM() sys.stderr.write('finished jcc.initVM\n') ....
Once I restart my apache, making a request from my browser, I've found that /var/log/apache2/error.log has only:
And therefore it will get stuck in the line jcc.initVM(). (When the mod_wsgi is set up as embedded mode, there's not a problem.)
Here is my /etc/apache2/sites-available/default:
WSGIDaemonProcess site user=ross group=ross threads=1 WSGIProcessGroup site WSGIScriptAlias / /home/ross/apache/django.wsgi <Directory /home/ross/apache/> Order deny,allow Allow from all </Directory>
And lastly, I discover that within the source code of jcc (jcc.cpp), it dangles in the function:
JNI_CreateJavaVM(&vm, (void **) &vm_env, &vm_args)
How you can solve the issue?
libapache2-mod-wsgi 2.3-1 jcc 2.1 python 2.5 Apache 2.2.9-8ubuntu3 Ubuntu 8.10
Please make reference to http://code.google.com/p/modwsgi/issues/detail?id=131 for that discussion particulars.
In a nutshell, the mod_wsgi will block signals for that daemon program, which might make initVM does not work. In addition based on Andi from jcc, initVM are only able to be known as in the primary thread, and you can get further problem too.
Well, I made the decision to maneuver the search code with initVM() to some totally separate process and reduced the problem.
The treatment for this issue was incorporated in mod_wsgi 2.4.