code: def restart(self, timeout=None):
          
          msg = { "value": "Restart requested by " + self.username + "via the Splunk SDK for Python"}
          # This message will be deleted once the server actually restarts.
          self.messages.create(name="restart_required", **msg)
          result = self.post("server/control/restart")
          if timeout is None:
              return result
          start = datetime.now()
          diff = timedelta(seconds=timeout)
          while datetime.now() - start < diff:
              try:
                  self.login()
                  if not self.restart_required:
                      return result
              except Exception as e:
                  sleep(1)
          raise Exception( "Operation time out.")
docs: Restarts this Splunk instance.
  
          The service is unavailable until it has successfully restarted.
  
          If a *timeout* value is specified, ``restart`` blocks until the service
          resumes or the timeout period has been exceeded. Otherwise, ``restart`` returns
          immediately.
  
          :param timeout: A timeout period, in seconds.
          :type timeout: ``integer``