为什么GEVENT上与Apache + mod_wsgi的烧瓶中的应用是提高NotImplementedError? [英] Why gevent on a Flask app with Apache + mod_wsgi is raising NotImplementedError?
问题描述
我在与Apache(mod_wsgi的)我的部署应用程序瓶问题
和GEVENT一个共享的主机(Webfaction)。
I'm having an issue deploying my Flask app with Apache (mod_wsgi) and gevent on a shared hosting (Webfaction).
该应用程序在由瓶提供的开发服务器,但是当我
尝试部署它,我得到日志文件中出现以下错误:
The application works fine in the development server provided by Flask, but when I try to deploy it I get the following error in log file:
[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-请求异步模块以
使并发的HTTP请求。
我试图谷歌左右,但我发现的唯一的建议就是叫
I need gevent because I'm using the python-requests' async module to make concurrent HTTP requests. I tried to Google around but the only advice I found is to to call
from gevent import monkey
monkey.patch_all()
这是我已经做我的code的东西。
something that I already do in my code.
WSGIDaemonProcess
的值是:
WSGIDaemonProcess myapp processes=5 python-path=/home/myusername/webapps/myapp/lib/python2.7 threads=1
下面是我的httpd.conf: http://pastebin.com/eWygicJH
Here is my httpd.conf: http://pastebin.com/eWygicJH
任何人有任何建议来解决这个问题?
Anybody has any advice to solve this issue?
推荐答案
好像我找到了解决办法喽。下面的指令解决了我的问题:
It seems like i found the solution myself. The following directive solved my issue:
WSGIApplicationGroup %{GLOBAL}
这个想法来自另一个回答在这里,建议设置为WSGIApplicationGroup GLOBAL解决了WSGI过程中的问题该保持崩溃。 从WSGI文档:
The idea comes from another answer where it is suggested to set WSGIApplicationGroup to GLOBAL to solve a problem with a WSGI process that keep crashing. From WSGI documentation:
要强制特定的WSGI应用程序中内运行的第一个
创建Python的子间preTER时Python会被初始化时,
WSGIApplicationGroup指令应采用和组设置为
'%{GLOBAL}。
To force a specific WSGI application to be run within the very first Python sub interpreter created when Python is initialised, the WSGIApplicationGroup directive should be used and the group set to '%{GLOBAL}'.
不能完全理解为什么这个指令解决我的问题,但它确实。我会很乐意,如果有人能够用简单的英语来解释这个给我; - )
Cannot fully understand why this directive solve my issue but it does. I will be more than happy if someone is able to explain this to me in plain English ;-)
这篇关于为什么GEVENT上与Apache + mod_wsgi的烧瓶中的应用是提高NotImplementedError?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!