title: Python socket recv data in while loop not stopping
body: <p>While im trying to recv data with a <code>while loop</code> the loop not stopping even when there is no data</p>
  
  <pre><code>import socket
  
  
  class Connect:
      connect = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  
      def __init__(self, server_ip, server_port):
          self.connect.connect((server_ip, server_port))
  
      def recv(self):
          data_ls = []
          while True:
              data = self.connect.recv(2048)
              if not data: # after getting the first data
                  break #    Python wont come to this "if" so it wont break!
  
              data = data.decode('utf-8')
              data_ls.append(data)
          return data_ls
  </code></pre>