code: def __receiver_loop(self):
          
          log.info("Starting receiver loop")
          notify_disconnected = True
          try:
              while self.running:
                  try:
                      while self.running:
                          frames = self.__read()
  
                          for frame in frames:
                              f = utils.parse_frame(frame)
                              if f is None:
                                  continue
                              if self.__auto_decode:
                                  f.body = decode(f.body)
                              self.process_frame(f, frame)
                  except exception.ConnectionClosedException:
                      if self.running:
                          #
                          # Clear out any half-received messages after losing connection
                          #
                          self.__recvbuf = b''
                          self.running = False
                          notify_disconnected = True
                      break
                  finally:
                      self.cleanup()
          finally:
              with self.__receiver_thread_exit_condition:
                  self.__receiver_thread_exited = True
                  self.__receiver_thread_exit_condition.notifyAll()
              log.info("Receiver loop ended")
              self.notify('receiver_loop_completed')
              if notify_disconnected:
                  self.notify('disconnected')
              with self.__connect_wait_condition:
                  self.__connect_wait_condition.notifyAll()
docs: Main loop listening for incoming data.