我是龙卷风的新手,所以我按照龙卷风的指导练习,当我来使用Coroutines时,例子说:来自龙卷风进口gen
@gen.coroutine
def fetch_coroutine(url):
http_client = AsyncHTTPClient()
response = yield http_client.fetch(url)
# In Python versions prior to 3.3, returning a value from
# a generator is not allowed and you must use
# raise gen.Return(response.body)
# instead.
return response.body
Run Code Online (Sandbox Code Playgroud)
当我运行这个测试时,它会在发生器内部引发语法错误'return',所以我取消注释建议,如下所示:import tornado.httpserver import tornado.ioloop import tornado.options import tornado.web
from tornado.options import define, options
define("port", default=8888, help="run on the given port", type=int)
from tornado import gen
from tornado.httpclient import AsyncHTTPClient
@gen.coroutine
def fetch_coroutine(url):
http_client = AsyncHTTPClient()
response = …Run Code Online (Sandbox Code Playgroud)