I am trying to make my client socket non-blocking. But unsuccessful. I'm not sure how to fix it.
I am trying to build a simple chat box and I am using tkinter for the GUI.

**The main part that is to note is the *while loop* that I have segmented within the code**

My client code is: 

```
    .
    .
    .
    class GroupFrame(Frame):
        def __init__(self, master):
            super().__init__(master)
            global memList
            global rootHome
            self.master.geometry("400x500")
            self.master.resizable(width=FALSE, height=FALSE)
            self.master.title("PowerPuff Chat Girls")

            #TextArea
            self.ChatLog = Text(self, bd=0, bg="light grey", height="13", width="55", font="Arial")
            self.ChatLog.insert(END, 'Welcome to the PowerPuff Chat, ' + username + '\n', 'INIT')
            self.ChatLog.config(state=DISABLED)
            self.ChatLog.tag_config('INIT', foreground='red', justify=CENTER)
            self.ChatLog.tag_config('BLUE', foreground='blue', justify=LEFT)
            self.ChatLog.tag_config('BLK', foreground='black', justify=RIGHT)

            #ScrollBar
            self.scrollbar = Scrollbar(self, command = self.ChatLog.yview, cursor="heart")
            self.ChatLog['yscrollcommand'] = self.scrollbar.set

            #EntryBox
            self.EntryBox = Text(self, bg="white", width="29", height="5", font="Arial")
            self.EntryBox.bind("<KeyRelease-Return>", lambda event: sendData(self.EntryBox.get(1.0, END)))

            #SendButton
            self.SendButton = Button(self, font=30, text="Send", width="11", height=1,
                            bg="white", fg='navy blue', activebackground="#FACC2E",  command=lambda: sendData(self.EntryBox.get(1.0, END)))

            #Place them on Screen
            self.scrollbar.place(x=380, y=6, height=386)
            self.ChatLog.place(x=8, y=6, height=405, width=370)
            self.EntryBox.place(x=128, y=425, height=60, width=248)
            self.SendButton.place(x=6, y=425, height=60)

            def sendData(param):
                if param == '\n\n':
                    self.EntryBox.delete(1.0, END)
                    return
                if len(param) > 1:
                    if '\n\n' in param:
                        # strip both the carriage return and appened with only one.
                        param = param.rstrip('\n')
                        param = param + '\n'
                    self.EntryBox.delete(1.0, END)
                    insertText(1, '>>' + param)
                    s.sendall(str.encode(param))
                    # data = s.recv(4500)

            def inspectData(data):
                if 'joined the chat **\n' in data.decode('utf-8'):
                    insertText(3, data.decode('utf-8'))
                else:
                    insertText(2, '>>' + data.decode('utf-8'))
                self.ChatLog.see(END)  # this shows the END of the chatlog; auto scroll down

            def insertText(num, param):
                self.ChatLog.config(state=NORMAL)
                if num == 1:
                    self.ChatLog.insert(END, param, 'BLK')
                if num ==2 :
                    self.ChatLog.insert(END, param, 'BLUE')
                if num ==3:
                    self.ChatLog.insert(END, param, 'INIT')
                self.ChatLog.config(state=DISABLED)

  *******************************************************
             while True:
                try:
                    data = s.recv(4096)
                    if(data):
                         inspectData(data)
                except:
                    break
 *******************************************************

page = Tk()
page.geometry("400x500")
page.resizable(width=FALSE, height=FALSE)
pf = HomeFrame(page)
page.mainloop()

```

With my current code, when I run it the client just freezes when it is currently in the *GroupFrame* Frame.
I am not sure why this happens. And If i haven't made my question clear please let me know so I can provide some images and parts of code that will help.