code: def _runForever(self, stop_event):
          
          while(not stop_event.is_set()):
              state = self.pusher.connection.state
  
              if (state is not "connecting" and
                      state is not "connected"):
                  self.logger.warning(
                      "Pusher seems to be disconnected, trying to reconnect")
                  self.pusher.connect()
  
              stop_event.wait(0.5)
docs: Runs the main loop
  
          Arguments:
              stop_event: threading.Event() as a stop signal