我像这样启动我的烧瓶应用程序:
#!flask/bin/python
from app import app_instance
from gevent.pywsgi import WSGIServer
#returns and instance of the application - using function to wrap configuration
app = app_instance()
http_server = WSGIServer(('',5000), app)
http_server.serve_forever()
然后,当我尝试执行此代码时,请求调用会阻塞,直到原始请求超时。我基本上是在同一个烧瓶应用程序中调用网络服务。我对gevent有什么误解?当 i/o 事件发生时,线程不会屈服吗?
@webapp.route("/register", methods=['GET', 'POST'])
def register():
form = RegistrationForm(request.form, csrf_enabled=False)
data = None
if request.method == 'POST' and form.validate():
data= {'email': form.email, 'auth_token': form.password,
'name' : form.name, 'auth_provider' : 'APP'}
r = requests.post('http://localhost:5000', params=data)
print('status' + str(r.status_code))
print(r.json())
return render_template('register.html', form=form)