Tornado: Is the RequestHandler.on_finish() method guaranteed to be called?

0

Issue

As the title asked: Is the RequestHandler.on_finish() method guaranteed to be called? Even if, say, the .post() method had an unhandled Exception?

Solution

Yes, on_finish is always called even when an unhandled exception occurs.

Tornado runs the handler method within a try...except block. So when there’s an unhandled exception, Tornado generates a 500 error response and calls the finish() method to close the request which in turn calls the on_finish() method.

Answered By – xyres

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More