code: def run(self):
          
          _logger.info('Start dispatcher')
          if dispatcher_env_vars.NNI_MODE == 'resume':
              self.load_checkpoint()
  
          while True:
              command, data = receive()
              if data:
                  data = json_tricks.loads(data)
  
              if command is None or command is CommandType.Terminate:
                  break
              if multi_thread_enabled():
                  result = self.pool.map_async(self.process_command_thread, [(command, data)])
                  self.thread_results.append(result)
                  if any([thread_result.ready() and not thread_result.successful() for thread_result in self.thread_results]):
                      _logger.debug('Caught thread exception')
                      break
              else:
                  self.enqueue_command(command, data)
                  if self.worker_exceptions:
                      break
  
          _logger.info('Dispatcher exiting...')
          self.stopping = True
          if multi_thread_enabled():
              self.pool.close()
              self.pool.join()
          else:
              self.default_worker.join()
              self.assessor_worker.join()
  
          _logger.info('Terminated by NNI manager')
docs: Run the tuner.
          This function will never return unless raise.