When should we add this decorator ? what is the benefits of adding this decorator ? what's the differences between with tornado.gen?
I will be very appreciate if anyone could give me some details
When should we add this decorator ? what is the benefits of adding this decorator ? what's the differences between with tornado.gen?
I will be very appreciate if anyone could give me some details
@asynchronous
is a promise to call self.finish()
instead of letting the request be finished automatically. This allows you to use asynchronous operations via callbacks.
@gen.coroutine
(and @gen.engine
, which is mostly obsolete) give the yield
keyword special meaning, allowing you to use asynchronous operations via Futures and Tasks.
Use @gen.coroutine
when you use the yield
keyword, and @asynchronous
when you use callbacks. In Tornado 3.0 it was sometimes necessary to use both together (and put @asynchronous
first), but since Tornado 3.1 there is no reason to do so and you should only use one or the other.