学习tornado遇到一段代码 大神们帮我解释下,tornado大神,import torna


import tornado.ioloopfrom tornado.httpclient import AsyncHTTPClientimport functoolsdef fetch():    response = yield functools.partial(AsyncHTTPClient().fetch, 'http://jinri.info')    print responsegen = fetch()f = gen.next()def callback(response):    try:        gen.send(response)    except StopIteration:        passf(callback)print 'here'tornado.ioloop.IOLoop.instance().start()

为什么f(acllback)在print 'here'之后执行tornado.ioloop.IOLoop.instance().start()这行代码的作用什么?用debug看程序运行的流程,在执行了tornado.ioloop.IOLoop.instance().start()之后,response才有结果,然后执行callback()回调,这个执行顺序也不是特别明白

在学习异步调用 看这代码卡主了.... 麻烦大家帮我解答下

编橙之家文章,

评论关闭