This code is not working:
>>>
# coding: utf-8
from functools import partial
from tornado import web, gen, ioloop
def hello(param, callback):
ioloop.IOLoop.instance().add_callback(partial(callback, param))
class MainHandler(web.RequestHandler):
@gen.engine
@web.asynchronous
def get(self):
res = yield gen.Task(hello, "hello!\n")
raise Exception("Oops!")
self.write(res)
self.finish()
application = web.Application([
(r"/", MainHandler),
], debug=True)
if __name__ == "__main__":
application.listen(8888)
ioloop.IOLoop.instance().start()
>>>
But if you change the order of the gen.engine and the web.asynchronous
decorators, then it works. Checked on latest git version.
> For RequestHandler
> <http://www.tornadoweb.org/documentation/web.html#tornado.web.RequestHandler>
> get/post/etc methods, this means that both the tornado.gen.engine
> <http://www.tornadoweb.org/documentation/gen.html#tornado.gen.engine>
> and tornado.web.asynchronous
> <http://www.tornadoweb.org/documentation/web.html#tornado.web.asynchronous>
> decorators must be used (*in either order*).
May be the gen.engine.__doc__ should be updated? Or is this a bug?
Thanks.
--
Andrew
-Ben
2012/1/23 Андрей Григорьев <and...@ei-grad.ru>: