rescuing CPU from endless loop hell on interactive console

This commit is contained in:
evilchili 2024-03-08 14:40:44 -08:00
parent d2f4a85cd5
commit 912d3fccd7

View File

@ -45,18 +45,20 @@ class RequestHandler(socketserver.StreamRequestHandler):
"""
while True:
self.data = self.rfile.readline().strip().decode()
logger.debug(f"{self.data = }")
try:
cmd = self.data[0:4].strip().upper()
args = self.data[5:]
except IndexError:
self.send(f"ERR Command not understood '{cmd}'")
sleep(0.001)
continue
if not cmd:
sleep(0.001)
continue
elif cmd not in self.supported_commands:
self.send(f"ERR Unknown Command '{cmd}'")
sleep(0.001)
continue
elif cmd == "KTHX":
return self.send("KBAI")