Non-responsive apache + mod_wsgi after installing scipy

Solution 1:

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:

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.

Solution 2:

Another solution that fit my way of configuring WSGI was changing the WSGIScriptAlias line:

WSGIDaemonProcess website user=user group=group python-path=/path/to/venv/website:/path/to/venv/lib/python2.7/site-packages
WSGIScriptAlias /website /path/to/venv/website/ process-group=website application-group=%{GLOBAL}

<Location /website>
        WSGIProcessGroup website

<Directory /path/to/venv/website>
        WSGIScriptReloading On
                Allow from all
                Require all granted

note the attributes

process-group=website application-group=%{GLOBAL}

which are usually not required