On Tuesday, October 9, 2012 1:09:23 AM UTC+8, Ben Darnell wrote:
> In general AsyncHTTPClient should be able to handle multiple requests
> concurrently, but there is one part of it that does block the IOLoop:
> DNS resolution. If your DNS calls are slow then you will see problems
> like what you're describing. The best way to deal with slow DNS in
> tornado 2.4 is to compile libcurl with c-ares support (which is not
> the default, so you'll probably have to build it yourself instead of
> getting it from your distribution's package manager) and use
> CurlAsyncHTTPClient. In 3.0 you'll be able to use a thread pool with
> SimpleAsyncHTTPClient.
> -Ben
> On Mon, Oct 8, 2012 at 12:34 AM, Jet Vster <jetv...@gmail.com<javascript:>>
> wrote:
> >> import logging
> >> import tornado.httpserver
> >> import tornado.ioloop
> >> import tornado.web
> >> from tornado import gen
> >> from tornado.web import asynchronous
> >> from tornado.httpclient import AsyncHTTPClient
> >> class MainHandler(tornado.web.RequestHandler):
> >> @asynchronous
> >> @gen.engine
> >> def get(self):
> >> http_client = AsyncHTTPClient()
> >> self.write("finish")
> >> response = yield gen.Task(http_client.fetch,
> >> "http://examplay.com",request_timeout=4)
> >> if response.error:
> >> self.write('except')
> >> else :
> >> self.write(response.body)
> >> self.flush()
> >> self.finish()
> >> settings = {
> >> #"debug": True,
> >> }
> >> application = tornado.web.Application([
> >> (r"/", MainHandler),
> >> ], **settings)
> >> if __name__ == "__main__":
> >> http_server = tornado.httpserver.HTTPServer(application)
> >> http_server.listen(8083)
> >> tornado.ioloop.IOLoop.instance().start()
> > when url is wrong,it alows throw the exception 'timeout'
> > then i send Multi requests in the same time, tornado will process
> request
> > one by one.
> > How to process multi AsyncHTTPClient on the same time?