EDIT: It works now after getting rid of the “processes” in WSGIDaemonProcess
I’ve been having memory usage issues and wanted to monitor the possibility of memory leaks by using a wsgi middleware called dozer: http://pypi.python.org/pypi/Dozer.
Here are the apache error logs:
AssertionError: Dozer middleware is not usable in a multi-process environment
Here is the code snippet from wsgi.py:
from django.core.wsgi import get_wsgi_application
from dozer import Dozer
application = get_wsgi_application()
application = Dozer(application)
This code was all run in manage.py’s shell and there were no errors.
Here is the specific error that displays:
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
The installed dozer egg is up to date (python 2.7), maybe the server needs to be specially configured for something like this?
Here are my wsgi settings:
ServerRoot "/path/django/apache2"
LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule wsgi_module modules/mod_wsgi.so
KeepAlive Off
Listen 28861
MaxSpareThreads 3
MinSpareThreads 1
ServerLimit 1
SetEnvIf X-Forwarded-SSL on HTTPS=1
ThreadsPerChild 5
WSGIDaemonProcess django threads=12 python-path=/path/django:/path/django/DareHut:/path/django/lib/python2.7
WGIProcessGroup django
WSGIRestrictEmbedded On
WSGILazyInitialization On
WSGIScriptAlias / /path/django/DareHut/DareHut/wsgi.py
What should I do? Thanks
Post the the mod_wsgi configuration from Apache and read:
http://code.google.com/p/modwsgi/wiki/ProcessesAndThreading
For it to work you cannot use a multiprocess configuration.
This means you cannot use mod_wsgi embedded mode on a UNIX system.
Even when you use daemon mode, you must use a configuration where there is only a single process in the daemon process group.
There is a caveat on doing that though. Do no use the ‘processes=1’ option to WSGIDaemonProcess to do that. You should leave out the ‘processes’ option altogether and let it default to a single process.
Any use of the ‘processes’ option will cause ‘wsgi.multiprocess’ to be flagged as True, which will cause Dozer to complain. Any use of that option, even with the value ‘1’, triggering that flag is by design so it is possible to flag a server as part of a multiprocess arrangement, even with a single process, when load balancing across multiple Apache servers.
So use:
Likely you have used the ‘processes’ option, or have forgot WSGIProcessGroup and aren’t actually running in daemon mode but in embedded mode by mistake.
BTW, if you are seeing it as ‘200 Error’ in the tab label of the browser is a minor bug in mod_wsgi 3.4 (if that is what you are using). The return HTTP status code is still 500 as it should be so all is interpreted as it should, but mod_wsgi isn’t clearing the status line properly so Apache will replace it with its own 500 status line and so the status line used in the tab label is wrong.