def METHOD_NAME():
  """Executes tasks indefinitely."""
  # Defer heavy task imports to prevent issues with multiprocessing.Process
  from clusterfuzz._internal.bot.tasks import commands
  clean_exit = False
  while True:
    stacktrace = ''
    exception_occurred = False
    task = None
    # This caches the current environment on first run. Don't move this.
    environment.reset_environment()
    try:
      # Run regular updates.
      update_task.run()
      update_task.track_revision()
      if environment.is_uworker():
        # Batch tasks only run one at a time.
        sys.exit(utasks.uworker_bot_main())
      task = tasks.get_task()
      if not task:
        continue
      with _Monitor(task):
        with task.lease():
          # Execute the command and delete the task.
          commands.process_command(task)
    except SystemExit as e:
      exception_occurred = True
      clean_exit = e.code == 0
      if not clean_exit and not isinstance(e, untrusted.HostError):
        logs.log_error('SystemExit occurred while working on task.')
      stacktrace = traceback.format_exc()
    except commands.AlreadyRunningError:
      exception_occurred = False
    except Exception:
      logs.log_error('Error occurred while working on task.')
      exception_occurred = True
      stacktrace = traceback.format_exc()
    if exception_occurred:
      # Prevent looping too quickly. See: crbug.com/644830
      failure_wait_interval = environment.get_value('FAIL_WAIT')
      time.sleep(utils.random_number(1, failure_wait_interval))
      break
  task_payload = task.payload() if task else None
  return stacktrace, clean_exit, task_payload