From a2a4db3e3d2e08d293224d6917d3318f96b6c28c Mon Sep 17 00:00:00 2001 From: "Richard Horton (hortonr6)" Date: Wed, 15 Nov 2017 17:01:54 +0000 Subject: [PATCH] Fixed infinite loop Turns out the seemingly random crashes we were having were actually being caused by an infinite while loop that was created when the user tried to send a message whilst the entry box was blank as it just kept on checking for a message without letting the user alter anything. The function now just quits early when the message is blank --- Client.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Client.py b/Client.py index 1f92009..4921ec4 100644 --- a/Client.py +++ b/Client.py @@ -50,9 +50,9 @@ def sendMessage(event=None): interface and then takes this input from the user and feeds it to the chatbot/server, allowing it to respond to the input appropriately.''' - sMessage = "" - while sMessage is None or sMessage == "": #loops through until user actually says something - sMessage = userInput.get() #input from user, needs to come from interface + sMessage = userInput.get() + if sMessage is None or sMessage == "": #Checks if the user has actually entered anything before sending + return None #Ends the function before any message is sent to prevent sending of blank message thisSocket.send(sMessage.encode()) chatHistory.configure(state="normal")