新手完全不懂tornado.concurrent.Future

官方例子:

pythonfrom 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 对象,最后又返回它!!已经痛苦了几天了!!大神来解救下我吧

阅读 6.4k
1 个回答
新手上路,请多包涵

你看漏这句了吧

my_future.set_result(f.result())

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题