Skip to content
Advertisement

Calling a Tornado handler in another handler

I want to split a Tornado handler in two handlers. In the first handler, I want send a command to a sensor. In the second handler, I want to wait for a response from the sensor.

Is this possible? Or I can’t call an handler from another? If it’s possible, how I can call this second handler?

Thank you very much.

Advertisement

Answer

I know that original post was asked years ago, but since accepted answer doesn’t solve the question asked, and I do believe I have the proper solution, as I had a need for it. Also, if some poor soul is Googling for the same issue, hopefully they will find this.

class OneHandler(RequestHandler):
    def get(self, id):
        AnotherHandler(self.application, self.request).get(id)

Here you can call “AnotherHandler” from within “OneHandler”

Advertisement