【问题标题】:Tornado AsyncHTTPClient behavior on slow requestsTornado AsyncHTTPClient 对慢速请求的行为
【发布时间】:2014-12-11 07:50:59
【问题描述】:

给出这个基本示例:

import tornado.gen
import tornado.httpclient
import tornado.web
import tornado.ioloop
import tornado.web


class MainHandler(tornado.web.RequestHandler):
    @tornado.web.asynchronous
    @tornado.gen.engine
    def get(self):
        client = tornado.httpclient.AsyncHTTPClient()
        response = yield tornado.gen.Task(client.fetch, 'http://slowserver-with-a-fake-5s-sleep')
        self.write(str(response.code))
        self.finish()


application = tornado.web.Application([
    (r"/", MainHandler),
])

if __name__ == "__main__":
    application.listen(9999)
    tornado.ioloop.IOLoop.instance().start()

当我点击“/”两次时,我可以看到我的人为缓慢的服务器接收到两个请求响应,中间间隔 5 秒。

tornado 不应该一个接一个地发出两个请求并等待响应吗?为什么ioloop被阻塞了?

龙卷风 2.4

【问题讨论】:

标签: asynchronous tornado


【解决方案1】:

哎呀,是的,答案很有趣。它只是 Chrome 将请求排队到相同的 url...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-03-02
    • 2017-09-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多