Flask WSGI application freezes when importing nltk

I followed the instructions here to create a one-factor flash application deployed on apache2 with mod-wsgi on ubuntu. All this works great when using the original flash application. However, when adding nltk import to the app jar, apache freezes (no 500).

I am using python 2.7 and nltk 2.0.4

Others seem to have had similar problems with other packages. Installation

WSGIApplicationGroup %{GLOBAL} 

VirtualHost's configuration seems to have helped. However, I still get the same behavior. Has anyone come across the same issue? Thanks for the help!

Here is the VirtualHost configuration file:

 <VirtualHost *:8080> # ---- Configure VirtualHost Defaults ---- ServerAdmin jsmith@whoi.edu DocumentRoot /home/bitnami/public_html/http <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /home/bitnami/public_html/http/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny Allow from all </Directory> # ---- Configure WSGI Listener(s) ---- WSGIDaemonProcess flaskapp user=www-data group=www-data processes=1 threads=5 WSGIScriptAlias /flasktest1 /home/bitnami/public_html/wsgi/flasktest1.wsgi <Directory /home/bitnami/public_html/http/flasktest1> WSGIProcessGroup flaskapp WSGIApplicationGroup %{GLOBAL} Order deny,allow Allow from all </Directory> # ---- Configure Logging ---- ErrorLog /home/bitnami/public_html/logs/error.log LogLevel warn CustomLog /home/bitnami/public_html/logs/access.log combined 

Here is a modified flask code

 #!/usr/bin/python from flask import Flask import nltk app = Flask(__name__) @app.route('/') def home(): return """<html> <h2>Hello from Test Application 1</h2> </html>""" @app.route('/<foo>') def foo(foo): return """<html> <h2>Test Application 1</2> <h3>/%s</h3> </html>""" % foo if __name__ == '__main__': "Are we in the __main__ scope? Start test server." app.run(host='0.0.0.0',port=5000,debug=True) 
+7
source share
1 answer

Where do you have:

 <Directory /home/bitnami/public_html/http/flasktest1> WSGIProcessGroup flaskapp WSGIApplicationGroup %{GLOBAL} Order deny,allow Allow from all </Directory> 

it should be:

 <Directory /home/bitnami/public_html/http> WSGIProcessGroup flaskapp WSGIApplicationGroup %{GLOBAL} Order deny,allow Allow from all </Directory> 

since you are not running your application in daemon mode or in the main interpreter due to the fact that directives are in the wrong context.

This Directory Directive then conflicts with one for the same directory, so merge them.

If you use mod_wsgi 3.0 or later, instead, perhaps release this second Directory block and use:

 WSGIDaemonProcess flaskapp threads=5 WSGIScriptAlias /flasktest1 /home/bitnami/public_html/wsgi/flasktest1.wsgi process-group=flaskapp application-group=%{GLOBAL} 

Please note that processes = 1 were dropped as this is the default and installation implies other things that you probably don't need. You also do not need to set a user / group, as it will automatically start as an Apache user.

+6
source

All Articles