Tornado: Is the RequestHandler.on_finish() method guaranteed to be called?
As the title asked: Is the
RequestHandler.on_finish() method guaranteed to be called? Even if, say, the
.post() method had an unhandled Exception?
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
Answered By – xyres