我在使用 Apache (mod_wsgi) 和 gevent 在共享主机 (Webfaction) 上部署我的 Flask 应用程序时遇到问题。
该应用程序在 Flask 提供的开发服务器中运行良好,但是当我尝试部署它时,我在日志文件中收到以下错误:
[Tue Mar 13 15:48:24 2012] [error] Traceback (most recent call last):
[Tue Mar 13 15:48:24 2012] [error] File "evdns.pxi", line 78, in gevent.core.__evdns_callback (gevent/core.c:6300)
[Tue Mar 13 15:48:24 2012] [error] File "/home/username/.virtualenvs/staging/lib/python2.7/site-packages/gevent/hub.py", line 297, in switch_args
[Tue Mar 13 15:48:24 2012] [error] File "/home/username/.virtualenvs/staging/lib/python2.7/site-packages/gevent/hub.py", line 290, in switch
[Tue Mar 13 15:48:24 2012] [error] File "/home/username/.virtualenvs/staging/lib/python2.7/site-packages/gevent/hub.py", line 135, in get_hub
[Tue Mar 13 15:48:24 2012] [error] NotImplementedError: gevent is only usable from a single thread
我需要 gevent,因为我正在使用python-requests 的异步模块来发出并发 HTTP 请求。我试着用谷歌搜索,但我发现的唯一建议是打电话
from gevent import monkey
monkey.patch_all()
我已经在我的代码中做的事情。
的值为WSGIDaemonProcess
:
WSGIDaemonProcess myapp processes=5 python-path=/home/myusername/webapps/myapp/lib/python2.7 threads=1
这是我的 httpd.conf: http: //pastebin.com/eWygicJH
有人对解决这个问题有什么建议吗?