From 912d3fccd78d0e5197f2a4a31401ea179892c52b Mon Sep 17 00:00:00 2001 From: evilchili Date: Fri, 8 Mar 2024 14:40:44 -0800 Subject: [PATCH] rescuing CPU from endless loop hell on interactive console --- croaker/server.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/croaker/server.py b/croaker/server.py index a341211..e13d570 100644 --- a/croaker/server.py +++ b/croaker/server.py @@ -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")