Promote the currently running task.
432859
async def promote(self, name, user, info=None):
        '''
        
        '''
        task = asyncio.current_task()

        synt = getattr(task, '_syn_task', None)

        if synt is not None:

            if synt.root is None:
                return synt

            synt.root.kids.pop(synt.iden)
            synt.root = None
            return synt

        return await s_task.Task.anit(self, task, name, user, info=info)
41620
def execute(self, env, args):
        

        # extract args
        old_task_name = args.old_task_name
        new_task_name = args.new_task_name

        if old_task_name == new_task_name:
            raise errors.FocusError(u'Could not rename task to itself')

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

        env.task.rename(old_task_name, new_task_name)
1373613
def promote(self, lane, svcs=None, meta=None):
        """"""

        svcs, meta, lane = self._prep_for_release(lane, svcs=svcs, meta=meta)

        # iterate and mark as future release
        for svc in svcs:
            self.changes.append("Promoting: {}.release.future={}".format(svc, self.name))
            self.rcs.patch('service', svc, {
                "release": {"future": self.name}, # new way
                "statuses": {"future": time.time()},
            })

        return self
1179982
def push_current(self, project):
        """"""
        if __debug__:
            from .targets import ProjectTarget
            assert isinstance(project, ProjectTarget)
        self.saved_current_project.append(self.current_project)
        self.current_project = project
112439
def _promote(self, request_url):
        
        self._usage_recency.remove(request_url)
        self._usage_recency.add(request_url)
687049
public void doneOnSubTasksDone() {
		if (jp != null) return;
		synchronized (tasks) {
			jp = new JoinPoint<>();
			for (SubTask task : tasks) jp.addToJoinDoNotCancel(task.getProgress().getSynch());
		}
		jp.listenInline(new Runnable() {
			@Override
			public void run() {
				if (jp.hasError()) error(jp.getError());
				else done();
			}
		});
		jp.start();
	}
170703
def run(self):
        """"""
        try:
            while not self.stopped:
                scraperobj = jobs.get(False)
                self.setName(scraperobj.getName())
                try:
                    self.getStrips(scraperobj)
                finally:
                    jobs.task_done()
                    self.setName(self.origname)
        except Empty:
            pass
        except KeyboardInterrupt:
            thread.interrupt_main()
8797
public void runTask(Handler<Task> task) {
    if (currentTask == null) {
      currentTask = new Task(this);
      task.handle(currentTask);
    } else {
      queue.add(task);
    }
  }
1189788
def maybe_put_task(self):
        """"""
        try:
            task = next(self.tasks)
        except StopIteration:
            pass
        else:
            log.debug('Putting %s on queue', task)
            self.task_queue.put(task)
170798
def stack_push(self, key, value):
        
        task = Task.current_task()
        try:
            context = task._context_stack
        except AttributeError:
            task._context_stack = context = {}
        if key not in context:
            context[key] = []
        context[key].append(value)
1140132
def process_task(self):
        """"""
        pdu = RegisterForeignDevice(self.bbmdTimeToLive)
        pdu.pduDestination = self.bbmdAddress

        # send it downstream
        self.request(pdu)
477731
def current_task(self, args):
        
        ctask = self.nice_name if self.nice_name is not None else self.name
        if args is not None:
            if args.update:
                ctask = ctask.replace('%pre', 'Updating')
            else:
                ctask = ctask.replace('%pre', 'Loading')
        return ctask
5020
def promote(self, level=None):
        """"""

        if level is None:

            if len(self.fields) < 2:
                if self.level in ('region', 'division', 'state', 'ua'):
                    cls = self.get_class('us')
                else:
                    return None
            else:
                cls = self.get_class(self.fields[-2])
        else:
            cls = self.get_class(level)

        d = dict(self.__dict__.items())
        d['sl'] = self.sl

        return cls(**d)
1049518
def add_task(self, task_id=None, status=PENDING, runnable=True,
                 deps=None, new_deps=None, expl=None, resources=None,
                 priority=0, family='', module=None, params=None, param_visibilities=None, accepts_messages=False,
                 assistant=False, tracking_url=None, worker=None, batchable=None,
                 batch_id=None, retry_policy_dict=None, owners=None, **kwargs):
        
        assert worker is not None
        worker_id = worker
        worker = self._update_worker(worker_id)

        resources = {} if resources is None else resources.copy()

        if retry_policy_dict is None:
            retry_policy_dict = {}

        retry_policy = self._generate_retry_policy(retry_policy_dict)

        if worker.enabled:
            _default_task = self._make_task(
                task_id=task_id, status=PENDING, deps=deps, resources=resources,
                priority=priority, family=family, module=module, params=params, param_visibilities=param_visibilities,
            )
        else:
            _default_task = None

        task = self._state.get_task(task_id, setdefault=_default_task)

        if task is None or (task.status != RUNNING and not worker.enabled):
            return

        # for setting priority, we'll sometimes create tasks with unset family and params
        if not task.family:
            task.family = family
        if not getattr(task, 'module', None):
            task.module = module
        if not getattr(task, 'param_visibilities', None):
            task.param_visibilities = _get_default(param_visibilities, {})
        if not task.params:
            task.set_params(params)

        if batch_id is not None:
            task.batch_id = batch_id
        if status == RUNNING and not task.worker_running:
            task.worker_running = worker_id
            if batch_id:
                # copy resources_running of the first batch task
                batch_tasks = self._state.get_batch_running_tasks(batch_id)
                task.resources_running = batch_tasks[0].resources_running.copy()
            task.time_running = time.time()

        if accepts_messages is not None:
            task.accepts_messages = accepts_messages

        if tracking_url is not None or task.status != RUNNING:
            task.tracking_url = tracking_url
            if task.batch_id is not None:
                for batch_task in self._state.get_batch_running_tasks(task.batch_id):
                    batch_task.tracking_url = tracking_url

        if batchable is not None:
            task.batchable = batchable

        if task.remove is not None:
            task.remove = None  # unmark task for removal so it isn't removed after being added

        if expl is not None:
            task.expl = expl
            if task.batch_id is not None:
                for batch_task in self._state.get_batch_running_tasks(task.batch_id):
                    batch_task.expl = expl

        task_is_not_running = task.status not in (RUNNING, BATCH_RUNNING)
        task_started_a_run = status in (DONE, FAILED, RUNNING)
        running_on_this_worker = task.worker_running == worker_id
        if task_is_not_running or (task_started_a_run and running_on_this_worker) or new_deps:
            # don't allow re-scheduling of task while it is running, it must either fail or succeed on the worker actually running it
            if status != task.status or status == PENDING:
                # Update the DB only if there was a acctual change, to prevent noise.
                # We also check for status == PENDING b/c that's the default value
                # (so checking for status != task.status woule lie)
                self._update_task_history(task, status)
            self._state.set_status(task, PENDING if status == SUSPENDED else status, self._config)

        if status == FAILED and self._config.batch_emails:
            batched_params, _ = self._state.get_batcher(worker_id, family)
            if batched_params:
                unbatched_params = {
                    param: value
                    for param, value in six.iteritems(task.params)
                    if param not in batched_params
                }
            else:
                unbatched_params = task.params
            try:
                expl_raw = json.loads(expl)
            except ValueError:
                expl_raw = expl

            self._email_batcher.add_failure(
                task.pretty_id, task.family, unbatched_params, expl_raw, owners)
            if task.status == DISABLED:
                self._email_batcher.add_disable(
                    task.pretty_id, task.family, unbatched_params, owners)

        if deps is not None:
            task.deps = set(deps)

        if new_deps is not None:
            task.deps.update(new_deps)

        if resources is not None:
            task.resources = resources

        if worker.enabled and not assistant:
            task.stakeholders.add(worker_id)

            # Task dependencies might not exist yet. Let's create dummy tasks for them for now.
            # Otherwise the task dependencies might end up being pruned if scheduling takes a long time
            for dep in task.deps or []:
                t = self._state.get_task(dep, setdefault=self._make_task(task_id=dep, status=UNKNOWN, deps=None, priority=priority))
                t.stakeholders.add(worker_id)

        self._update_priority(task, priority, worker_id)

        # Because some tasks (non-dynamic dependencies) are `_make_task`ed
        # before we know their retry_policy, we always set it here
        task.retry_policy = retry_policy

        if runnable and status != FAILED and worker.enabled:
            task.workers.add(worker_id)
            self._state.get_worker(worker_id).tasks.add(task)
            task.runnable = runnable
445241
public function run()
    {
        $prefix = $this->notifyPrefix;
        
        $this->addNotification($prefix.'_start_run_tasks');
        
        foreach ($this->runSteps as $actionName => $stepInfos) {
            $context = null;
            if ($stepInfos->context !== null) {
                $context = $stepInfos->context;
            }
            
            if ($stepInfos->callback === null) {
                $this->addNotification($prefix.'_exec_'.$actionName, $context);
                continue;
            }
            
            $this->addNotification($prefix.'_run_'.$actionName, $context);

            if (is_callable($stepInfos->callback)) {
                $callback = $stepInfos->callback;
                $callback();
            }

            $this->addNotification($prefix.'_done_'.$actionName, $context);
        }
        
        $this->addNotification($prefix.'_end_run_tasks');
    }
1313749
def promote_to_main(self, move: chess.Move) -> None:
        """"""
        variation = self[move]
        self.variations.remove(variation)
        self.variations.insert(0, variation)
706865
function(task) {

		if (this._active_tasks.indexOf(task) == -1) {

			this._active_tasks.push(task);

		}

		this._enable();

		if (!this.is_running) {
			this._enable();
			this.is_running = true;
		}

	}