V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Tornado Documentation
http://www.v2ex.com/tornado/
Tornado on GitHub
https://github.com/facebook/tornado/
Tornado Gists
http://tornadogists.org/
guoran728
V2EX  ›  Tornado

新手完全不懂 tornado.concurrent.Future

  •  
  •   guoran728 · 2015-04-09 15:33:06 +08:00 · 5786 次点击
    这是一个创建于 3303 天前的主题,其中的信息可能已经有所发展或是发生改变。

    官方例子:

    from tornado.concurrent import Future

    def async_fetch_future(url):
    http_client = AsyncHTTPClient()
    my_future = Future()
    fetch_future = http_client.fetch(url)
    fetch_future.add_done_callback(
    lambda f: my_future.set_result(f.result()))
    return my_future
    什么协程,异步迷迷糊糊的!

    完全不懂 my_future = Future() 为什么要生成个 Future 对象,最后又返回它!!已经痛苦了几天了!!大神来解救下我吧

    1 条回复    2015-06-14 20:52:57 +08:00
    zhuangzhuang1988
        1
    zhuangzhuang1988  
       2015-06-14 20:52:57 +08:00
    这个在python中文档确实不多
    这个你得去找Java, C#的文档, python中的 Futurue类本身就是模仿的java.util.concurrent.Future类的.
    java的推荐http://book.douban.com/subject/2148132/
    C#的看这个https://msdn.microsoft.com/en-us/library/ff963556.aspx
    或者去了解下 js中的Promise.
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5457 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 05:47 · PVG 13:47 · LAX 22:47 · JFK 01:47
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.