Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am currently running a Centos 6.4 server, with Apache 2.2.15 and mod_wsgi 3.2. The server is hosting a django-based site (django 1.5.1, python 2.6.6). Everything was running fine until I installed scipy 0.12.0 via pip. Now, when I attempt to load the django app, the server does not respond, and it appears that child httpd processes that are spawned hang. Looking through my logs (/var/logs/httpd/error_log, my vhost error.log, and my system logs) yield no errors.

If I load my models, etc.. via the django manage.py shell, everything works fine, which leads me to believe it is a mod_wsgi issue.

Any thoughts on how to start troubleshooting this?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

Some third party packages for Python which use C extension modules, and this includes scipy and numpy, will only work in the Python main interpreter and cannot be used in sub interpreters as mod_wsgi by default uses. The result can be thread deadlock, incorrect behaviour or processes crashes. These is detailed in:

http://code.google.com/p/modwsgi/wiki/ApplicationIssues#Python_Simplified_GIL_State_API

The workaround is to force the WSGI application to run in the main interpreter of the process using:

WSGIApplicationGroup %{GLOBAL}

If running multiple WSGI applications on same server, you would want to start investigating using daemon mode because some frameworks don't allow multiple instances to run in same interpreter. This is the case with Django. Thus use daemon mode so each is in its own process and force each to run in main interpreter of their respective daemon mode process groups.

share|improve this answer
    
thank you much! That did the trick. –  MarkD Jun 7 '13 at 22:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.