Frage

I am using tornado 3.2 on python 2.7 and the asynchronous decorator is throwing errors. The error is :

[~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

And this is my code that uses decorator:

class UploadHandler(tornado.web.RequestHandler):
    @asynchronous
    def post(self):
      print "In post"
      self.redirect("/upload.html")

Any advice would be great

War es hilfreich?

Lösung

You need to use the fully qualified name:

class UploadHandler(tornado.web.RequestHandler):
    @tornado.web.asynchronous
    def post(self):
        print("In post")
        self.redirect("/upload.html")

Alternatively, you could import all of tornado.web to use the single name:

from tornado.web import *
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top