Execute specific task action
180016
def execute
      puts "Executing #{self.class.taskName} at #{Time::now}".primary
      begin
        self.action
      rescue => e
        puts "Executing #{self.class.taskName} failed".warning
        puts e.inspect.to_s.info
        puts e.backtrace.to_s.info
      end
    end
1014348
def make_task(name='',
              run_name='',
              **kwargs) -> Task:
  """"""
  ncluster_globals.task_launched = True

  name = ncluster_globals.auto_assign_task_name_if_needed(name)

  # tmux can't use . for session names
  tmux_session = name.replace('.', '=')
  tmux_window_id = 0
  util.log(f'killing session {tmux_session}')

  if not util.is_set("NCLUSTER_NOKILL_TMUX"):
    os.system(f'tmux kill-session -t {tmux_session}')
  os.system(f'tmux new-session -s {tmux_session} -n {tmux_window_id} -d')

  task = Task(name,
              tmux_session=tmux_session,  # propagate optional args
              run_name=run_name,
              **kwargs)
  ncluster_globals.register_task(task, run_name)
  return task
1008497
def execute(cls, stage, state, data, next_allowed_exec_time=None):
        """"""
        try:
            context = Context.from_state(state, stage)
            now = datetime.utcnow()
            if next_allowed_exec_time and now < next_allowed_exec_time:
                # task not allowed to run yet; put it back in the queue
                Queue.queue(stage, state, data, delay=next_allowed_exec_time)
            elif context.crawler.disabled:
                pass
            elif context.stage.rate_limit:
                try:
                    with rate_limiter(context):
                        context.execute(data)
                except RateLimitException:
                    delay = max(1, 1.0/context.stage.rate_limit)
                    delay = random.randint(1, int(delay))
                    context.log.info(
                        "Rate limit exceeded, delaying %d sec.", delay
                    )
                    Queue.queue(stage, state, data, delay=delay)
            else:
                context.execute(data)
        except Exception:
            log.exception("Task failed to execute:")
        finally:
            # Decrease the pending task count after excuting a task.
            Queue.decr_pending(context.crawler)
            # If we don't have anymore tasks to execute, time to clean up.
            if not context.crawler.is_running:
                context.crawler.aggregate(context)
843414
def execute_tasks(tasks,template_path)
      
      if File.exists?(File.expand_path(File.join(template_path,'tasks.rb')))
        load File.expand_path(File.join(template_path,'tasks.rb'))
      end
       
      tasks.each{
        |task|
        
        puts 'Running Task: ' + task
        
        task = replace_tags(task);
        
        options = task.split(', ')
        action = options.slice!(0)
        
        if(Tasks.respond_to?(action))
          Tasks.send action, options.join(', ')
        else
          send action, options.join(', ')
        end
        
      }
                  
    end
1085509
def execute(self, env, args):
        

        task_name = args.task_name

        if not env.task.exists(task_name):
            raise errors.TaskNotFound(task_name)

        if env.task.active and task_name == env.task.name:
            raise errors.ActiveTask

        # open in task config in editor
        task_config = env.task.get_config_path(task_name)

        if not _edit_task_config(env, task_config, confirm=True):
            raise errors.FocusError(u'Could not open task config: {0}'
                                    .format(task_config))
38889
def execute(self, env, args):
        

        task_name = args.task_name

        if task_name is None:
            if not env.task.active:
                raise errors.NoActiveTask
            task_name = env.task.name

        tasks = env.task.get_list_info(task_name)
        if not tasks:
            raise errors.TaskNotFound(task_name)

        _print_tasks(env, tasks)
849327
public void execute(Task task) {
    LOG.info(String.format("Executing task %s", task.getTaskId()));
    this.taskExecutor.execute(new TrackingTask(task));
  }
443287
public function execute()
	{
		// Incoming task
		$this->_task = strtolower(\Request::getCmd('task', \Request::getWord('layout', '')));

		// Check if the task is in the taskMap
		if (isset($this->_taskMap[$this->_task]))
		{
			$doTask = $this->_taskMap[$this->_task];
		}
		// Check if the default task is set
		elseif (isset($this->_taskMap['__default']))
		{
			$doTask = $this->_taskMap['__default'];
		}
		// Raise an error (hopefully, this shouldn't happen)
		else
		{
			throw new InvalidTaskException(Lang::txt('The requested task "%s" was not found.', $this->_task), 404);
		}

		$name = $this->_controller;
		$layout = preg_replace('/[^A-Z0-9_]/i', '', $doTask);
		if (!$this->_controller)
		{
			$cls = get_class($this);
			// Attempt to parse the controller name from the class name
			if ((ucfirst($this->_name) . 'Controller') != $cls
			 && preg_match('/(\w)Controller(.*)/i', $cls, $r))
			{
				$this->_controller = strtolower($r[2]);
				$name   = $this->_controller;
				$layout = preg_replace('/[^A-Z0-9_]/i', '', $doTask);
			}
			// Namepsaced component
			else if (preg_match('/(.?)Controllers\\\(.*)/i', $cls, $r))
			{
				$this->_controller = strtolower($r[2]);
				$name   = $this->_controller;
				$layout = preg_replace('/[^A-Z0-9_]/i', '', $doTask);
			}
			// No controller name found - single controller component
			else
			{
				$name = $doTask;
			}
		}

		// Instantiate a view with layout the same name as the task
		$this->view = new View(array(
			'base_path' => $this->_basePath,
			'name'      => $name,
			'layout'    => $layout
		));

		// Set some commonly used vars
		$this->view->set('option', $this->_option)
					->set('task', $doTask)
					->set('controller', $this->_controller);

		// Record the actual task being fired
		$doTask .= 'Task';

		// On before do task hook
		$this->_onBeforeDoTask();

		// Call the task
		$this->$doTask();
	}
361730
def perform(action_name, container, **kwargs):
    
    cf = container_fabric()
    cf.call(action_name, container, **kwargs)
1343931
def perform_action(
            self, action, machines, params, progress_title, success_title):
        """"""
        if len(machines) == 0:
            return 0
        with utils.Spinner() as context:
            return self._async_perform_action(
                context, action, list(machines), params,
                progress_title, success_title)
530092
def execute(self, env, args):
        

        task_name = args.task_name
        clone_task = args.clone_task

        if not env.task.create(task_name, clone_task):
            raise errors.FocusError(u'Could not create task "{0}"'
                                    .format(task_name))

        # open in task config in editor
        if not args.skip_edit:
            task_config = env.task.get_config_path(task_name)

            if not _edit_task_config(env, task_config, confirm=True):
                raise errors.FocusError(u'Could not open task config: {0}'
                                        .format(task_config))
52513
def execute_task(task_id,
                 verbosity=None,
                 runmode='run',
                 sigmode=None,
                 monitor_interval=5,
                 resource_monitor_interval=60):
    ''''''
    tf = TaskFile(task_id)

    # this will automatically create a pulse file
    tf.status = 'running'
    # write result file
    try:
        signal.signal(signal.SIGTERM, signal_handler)
        res = _execute_task(task_id, verbosity, runmode, sigmode,
                            monitor_interval, resource_monitor_interval)
    except KeyboardInterrupt:
        tf.status = 'aborted'
        raise
    except ProcessKilled:
        tf.status = 'aborted'
        raise ProcessKilled('task interrupted')
    finally:
        signal.signal(signal.SIGTERM, signal.SIG_DFL)

    if res['ret_code'] != 0 and 'exception' in res:
        with open(
                os.path.join(
                    os.path.expanduser('~'), '.sos', 'tasks', task_id + '.err'),
                'a') as err:
            err.write(f'Task {task_id} exits with code {res["ret_code"]}')

    if res.get('skipped', False):
        # a special mode for skipped to set running time to zero
        tf.status = 'skipped'
    else:
        tf.add_outputs()
        sig = res.get('signature', {})
        res.pop('signature', None)
        tf.add_result(res)
        if sig:
            tf.add_signature(sig)
        # **after** result file is created, remove other files
        #
        # NOTE: if the pulse is not removed. When another sos process checkes
        # the task is started very quickly so the task has satus 'pending',
        # the task might be considered already running.
        tf.status = 'completed' if res['ret_code'] == 0 else 'failed'

    return res['ret_code']
491824
public synchronized void executeTask(long jobId, int taskId, JobConfig jobConfig,
      Serializable taskArgs, RunTaskContext context) {
    Future<?> future = mTaskExecutionService
        .submit(new TaskExecutor(jobId, taskId, jobConfig, taskArgs, context, this));
    Pair<Long, Integer> id = new Pair<>(jobId, taskId);
    mTaskFutures.put(id, future);
    TaskInfo.Builder taskInfo = TaskInfo.newBuilder();
    taskInfo.setJobId(jobId);
    taskInfo.setTaskId(taskId);
    taskInfo.setStatus(Status.RUNNING);
    mUnfinishedTasks.put(id, taskInfo);
    mTaskUpdates.put(id, taskInfo.build());
    LOG.info("Task {} for job {} started", taskId, jobId);
  }
25892
protected void executeAction(Action action) {
        ProcessContext context = new ProcessContext(getProcessInstance().getKnowledgeRuntime());
        context.setNodeInstance(this);
        try {
            action.execute(context);
        } catch (Exception e) {
            String exceptionName = e.getClass().getName();
            ExceptionScopeInstance exceptionScopeInstance = (ExceptionScopeInstance)
                resolveContextInstance(ExceptionScope.EXCEPTION_SCOPE, exceptionName);
            if (exceptionScopeInstance == null) {
                throw new WorkflowRuntimeException(this, getProcessInstance(), "Unable to execute Action: " + e.getMessage(), e);
            }
            
            exceptionScopeInstance.handleException(exceptionName, e);
            cancel();
        }
    }
1055531
def _execute_module(self, module_name=None, module_args=None, tmp=None,
                        task_vars=None, persist_files=False,
                        delete_remote_tmp=True, wrap_async=False):
        
        if module_name is None:
            module_name = self._task.action
        if module_args is None:
            module_args = self._task.args
        if task_vars is None:
            task_vars = {}

        self._update_module_args(module_name, module_args, task_vars)
        env = {}
        self._compute_environment_string(env)
        self._temp_file_gibberish(module_args, wrap_async)

        self._connection._connect()
        result = ansible_mitogen.planner.invoke(
            ansible_mitogen.planner.Invocation(
                action=self,
                connection=self._connection,
                module_name=mitogen.core.to_text(module_name),
                module_args=mitogen.utils.cast(module_args),
                task_vars=task_vars,
                templar=self._templar,
                env=mitogen.utils.cast(env),
                wrap_async=wrap_async,
                timeout_secs=self.get_task_timeout_secs(),
            )
        )

        if ansible.__version__ < '2.5' and delete_remote_tmp and \
                getattr(self._connection._shell, 'tmpdir', None) is not None:
            # Built-in actions expected tmpdir to be cleaned up automatically
            # on _execute_module().
            self._remove_tmp_path(self._connection._shell.tmpdir)

        return result
1335830
def execute(args = nil)
      execute_task(args)
    rescue Interrupt => e
      raise e # Dont log if it's an interrupt
    rescue Exception => e
      Errdo.error(e, args) if Errdo.log_task_exceptions
      raise e
    end
1347026
def Execute(self, action, *args, **kw):
        
        action = self.Action(action, *args, **kw)
        result = action([], [], self)
        if isinstance(result, SCons.Errors.BuildError):
            errstr = result.errstr
            if result.filename:
                errstr = result.filename + ': ' + errstr
            sys.stderr.write("scons: *** %s\n" % errstr)
            return result.status
        else:
            return result