what does @tornado.web.asynchronous decorator mean?

python, tornado

Solution

`@tornado.web.asynchronous` prevents the the `RequestHandler` from automatically calling `self.finish()`. That's it; it just means Tornado will keep the connection open until you manually call `self.finish()`.

Code not using this decorator can block, or not. Using the decorator doesn't change that in any way.

As @Steve Peak said, you use the decorator for asynchronous requests, e.g. database retrieval.

Updated for Tornado 3.1+: If you use `@gen.coroutine`, you don't need to use `@asynchronous` as well. The older `@gen.engine` interface still requires `@asynchronous`, I believe.

Problem

- If code didn't use this decorator, is it non-blocking? - Why this name is asynchronous, it means add decorator let code asynchronous? - Why @tornado.gen always use with @tornado.web.asynchronous together?

Original source

Related problems