Unterstanding eventlet.wsgi.server [英] Unterstanding eventlet.wsgi.server

查看:338
本文介绍了Unterstanding eventlet.wsgi.server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个简单的Python程序:

I have this simple Python programm:

from eventlet import wsgi
import eventlet
from eventlet.green import time

def hello_world(env, start_response):
    print "got request"
    time.sleep(10)
    start_response('200 OK', [('Content-Type', 'text/plain')])
    return ['Hello, World!\n']

wsgi.server(eventlet.listen(('', 8090)), hello_world)

所以当我运行它时,打开 http:// localhost:8090 / 在我的浏览器上多次,获取请求仅在第一个请求已经处理后打印(10个之后)秒)。
似乎 eventlet.wsgi.server 正在同步处理请求。但我使用的是绿色 sleep 。播种怎么会发生这种情况?

So when i run it, and open http://localhost:8090/ on my browser multiple times, got request is only printed after the first request was already processed (after 10 seconds). It seems like eventlet.wsgi.server is processing the requests synchronously. But I am using the "green" sleep. sow how can this happen?

谢谢!

推荐答案

你必须使用如下的猴子补丁:

You have to use the monkey patch as below:

eventlet.patcher.monkey_patch(all=False, socket=True, time=True,
                          select=True, thread=True, os=True)

更多信息可能是从这个链接中找到。

More information could be found from this link.

这篇关于Unterstanding eventlet.wsgi.server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆