[tornado] quit main loop when should
add docstrings and fix some warnings by pylint