学习tornado遇到一段代码 大神们帮我解释下,tornado大神,import torna
学习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()回调,这个执行顺序也不是特别明白
在学习异步调用 看这代码卡主了.... 麻烦大家帮我解答下
编橙之家文章,
相关内容
- python 字典格式化字符串的问题,python字符串,>>&g
- 用heroku在国内部署app?,heroku国内app,我在用python做一个
- Vim ctags在同一文件中一个函数的两次定义只会跳转到一
- PySide 中是否必须在同一个函数中创建 QWidget 与 QApplic
- pyqt5 qml 信号槽连接,pyqt5qml信号连接,import QtQui
- Python 代码静态分析,python代码静态,有大量的Python代码
- 如何将PyCodeObject保存为pyc,pycodeobjectpyc,source = ope
- multi-mechanize如何实现ops 100的压力测试,multi-mechanizeop
- django html模板中for标签循环不能打印是什么原因,djan
- python import qiniu.rs报错 no module named in auth是什么原因,
评论关闭