我在python 2.7上使用tornado 3.2,异步装饰器抛出错误。错误是:
[~code]$ python server.py
Traceback (most recent call last):
File "server.py", line 15, in <module>
class UploadHandler(tornado.web.RequestHandler):
File "server.py", line 16, in UploadHandler
@asynchronous
NameError: name 'asynchronous' is not defined
这是我使用装饰器的代码:
class UploadHandler(tornado.web.RequestHandler):
@asynchronous
def post(self):
print "In post"
self.redirect("/upload.html")
任何建议都会很棒
答案 0 :(得分:2)
您需要使用完全限定名称:
class UploadHandler(tornado.web.RequestHandler):
@tornado.web.asynchronous
def post(self):
print("In post")
self.redirect("/upload.html")
或者,您可以导入所有tornado.web
以使用单个名称:
from tornado.web import *