Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tornado process data in request handler after return

Tags:

python

tornado

In a tornado request handler if I have to call function foo() which doesn't affect what's returned to the user, it makes sense to return result to the user first and then call foo(). Is it possible to do this easily in tornado (or with some third-party package)?

like image 731
kefeizhou Avatar asked Mar 11 '11 15:03

kefeizhou


1 Answers

It's extremely easy:

class Handler(tornado.web.RequestHandler):
    def get(self):
        self.write('response')
        self.finish() # Connection is now closed
        foo()
like image 89
A. Jesse Jiryu Davis Avatar answered Sep 30 '22 21:09

A. Jesse Jiryu Davis