Remove a task in this legion.
        If the task has active processes, an attempt is made to
        stop them before the task is deleted.
178649
def task_del(self, t):
        
        name = t._name
        if name in self._tasknames:
            del self._tasknames[name]
        self._tasks.discard(t)
        self._tasks_scoped.discard(t)
        try:
            t.stop()
        except:
            log = self._params.get('log', self._discard)
            log.error("Failed to stop processes for task %r -- %s", name, e, exc_info=log.isEnabledFor(logging.DEBUG))
        for pid in t.get_pids():
            self.proc_del(pid)
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;
		}

	}
164515
def clear(self):
        
        with self.__lock:
            # Empty the current queue
            try:
                while True:
                    self._queue.get_nowait()
                    self._queue.task_done()
            except queue.Empty:
                # Queue is now empty
                pass

            # Wait for the tasks currently executed
            self.join()
961242
def kill(self):
        
        logger.info('Sending SIGKILL to task {0}'.format(self.name))
        if hasattr(self, 'remote_client') and self.remote_client is not None:
            self.kill_sent = True
            self.remote_client.close()
            return
        if not self.process:
            raise DagobahError('task does not have a running process')
        self.kill_sent = True
        self.process.kill()
180630
def stop(task = :default)
      return nil unless tasks.keys.include?(task) && active?(task)
      time_taken = Time.now.to_f - tasks[task][:current].to_f
      tasks[task][:history] << { start: tasks[task][:current], stop: Time.now.to_f, time: time_taken }
      tasks[task][:current] = nil
      if retention && tasks[task][:history].size > retention then tasks[task][:history].shift end
      time_taken
    end
1290624
def end_task(self, name, success=True):
        
        self._running.remove(name)

        if success:
            self._completed.add(name)
            self._graph.remove(name, strategy=Strategy.orphan)
        else:
            self._cascade_failure(name)
1241341
def thread_stopped(self):
		
		task = self.task()
		if isinstance(task, WStoppableTask) is True:
			task.stop()
1153062
def task_remove_user(self, *args, **kwargs):
        
        if not self.cur_task:
            return
        i = self.task_user_tablev.currentIndex()
        item = i.internalPointer()
        if item:
            user = item.internal_data()
            self.cur_task.users.remove(user)
            item.set_parent(None)
1283794
def stop(*args):
    """"""
    if _debug: stop._debug("stop")
    global running, taskManager

    if args:
        sys.stderr.write("===== TERM Signal, %s\n" % time.strftime("%d-%b-%Y %H:%M:%S"))
        sys.stderr.flush()

    running = False

    # trigger the task manager event
    if taskManager and taskManager.trigger:
        if _debug: stop._debug("    - trigger")
        taskManager.trigger.set()
1358889
def unschedule(self, task_name):
        '''
        
        '''
        for greenlet in self.waiting[task_name]:
            try:
                gevent.kill(greenlet)
            except BaseException:
                pass
1298614
def stop(self):
        """"""
        with self._lock_c:
            for task in self.taskset:
                try:
                    task.stop()

                except TaskError as e:
                    # Task does not have a way to stop it.
                    # TODO: notify who?
                    pass
1076208
def terminate(self):
        
        logger.info('Sending SIGTERM to task {0}'.format(self.name))
        if hasattr(self, 'remote_client') and self.remote_client is not None:
            self.terminate_sent = True
            self.remote_client.close()
            return
        if not self.process:
            raise DagobahError('task does not have a running process')
        self.terminate_sent = True
        self.process.terminate()
847371
private void cleanup(boolean atStartup) {
        boolean allTasksIdle = false;
        while (!allTasksIdle) {
            int activeCount = 0;
            for (Task task: taskDao.listTasks()) {
                if (!task.getState().equals(Task.IDLE)) {
                    activeCount++;
                    if (!task.getState().equals(Task.CANCELING)) {
                        logger.info("Auto-canceling task " + task.getId() + " (" + task.getName() + ")");
                        taskDao.setTaskState(task.getId(), Task.CANCELING);
                        task.setState(Task.CANCELING);
                    }
                    if (atStartup) {
                        // We're cleaning up after an unclean shutdown.
                        // Since the TaskRunner isn't actually running, we make
                        // the direct call here to clean up the state in the
                        // database, marking it as canceled.
                        taskCanceled(task);
                    } else {
                        // In the normal case, the TaskRunner is running in a
                        // separate thread and we just need to request that
                        // it cancel at the next available opportunity.
                        cancelTask(task);
                    }
                }
            }
            if (activeCount == 0 || atStartup) {
                allTasksIdle = true;
            } else {
                logger.info("Waiting for " + activeCount + " task(s) to go idle.");
                sleepSeconds(1);
            }
        }
    }
800186
def delete_task(self, courseid, taskid):
        
        if not id_checker(courseid):
            raise InvalidNameException("Course with invalid name: " + courseid)
        if not id_checker(taskid):
            raise InvalidNameException("Task with invalid name: " + taskid)

        task_fs = self.get_task_fs(courseid, taskid)

        if task_fs.exists():
            task_fs.delete()
            get_course_logger(courseid).info("Task %s erased from the factory.", taskid)
543362
def thread_stopped(self):
		
		if self.__current_task is not None:
			task = self.__task_chain[self.__current_task]
			task.stop()
			self.__current_task = None
138672
def stop_old_tasks
      # only works when deployment is blocking
      return unless @options[:wait]

      Thread.new do
        stop = Ufo::Stop.new(@service, @options.merge(mute: true))
        while true
          stop.log "checking for old tasks and waiting for 10 seconds"
          stop.run
          sleep 10
        end
      end
    end
690132
function cancelTask(proc, taskId) {
  const taskProcs = proc.tasks[taskId];
  delete proc.tasks[taskId];

  for (const execId in taskProcs) {
    const taskCall = taskProcs[execId];
    if (taskCall && taskCall.cancel) {
      taskCall.cancel();
    }
  }
}