docs: def mainloop(self):
          """
          Handles events and calls their handler for infinity.
          """
          while self.keep_going:
              with self.lock:
                  if self.on_connect and not self.readable(2):
                      self.on_connect()
                      self.on_connect = None
                  if not self.keep_going:
                      break
                  self.process_once()