def handle_stream(self, stream, address):
"""
handle telnet connection
http://www.tornadoweb.org/en/stable/gen.html#tornado-gen-simplify-asynchronous-code
"""
stream.write(TELNET_PROMPT_PREFIX)
while True:
try:
command = yield stream.read_until(b'\n')
result = self.handle_command(command.decode().strip())
yield stream.write(result.encode() + TELNET_PROMPT_PREFIX)
except StreamClosedError:
break
评论列表
文章目录