如何让wsgi一次处理多个请求?

时间:2014-09-10 23:23:09

标签: python wsgi uwsgi

我想用uWSGI创建一个长轮询服务器。问题是由于某种原因,它一次只处理(或等待)一个请求。为了演示,以下示例具有相同的问题:

from gevent import monkey
monkey.patch_all()
import time

def application(env, start_response):
    start_response('200 OK', [('Content-Type', 'text/html')])
    for i in range(1, 10000):
        yield "<h1>%s</h1><br />" % i
        time.sleep(5)

以下内容也会显示相同的问题:

import gevent
from gevent import monkey
monkey.patch_all()
from gevent import pywsgi
from gevent import queue
import time

def issue(body):
    for i in range(1, 10000):
        body.put("<h1>%s</h1><br />" % i)
        time.sleep(5)

def application(env, start_response):
    body = queue.Queue()
    start_response('200 OK', [('Content-Type', 'text/html')])
    gevent.spawn(issue, body)
    return body

我使用sudo -u www-data uwsgi --gevent 100 --post-buffering=4096 --processes 4 --socket /run/uwsgi/uwsgi.sock --wsgi-file tmp.wsgi启动uwsgi,并尝试添加--async 100,但不做任何更改。

同样,我如何让wsgi一次处理多个请求?您应该能够同时看到镀铬计数中的两个选项卡。

更新:从chrome中的两个标签请求时,似乎只有这个问题。我怀疑这是由于浏览器的限制。

0 个答案:

没有答案