Delete task (does not influence its corresponding directory)

        :return: whether deletion is successful
        :raise: :class:`.TaskError` if the task is already deleted
163086
def delete(self):
        
        if not self._deleted:
            if self.api._req_lixian_task_del(self):
                self._deleted = True
                return True
        raise TaskError('This task is already deleted.')
889908
def uninstall_task(self, name):
    
    if name in self._task_type_by_name:
      self._task_type_by_name[name].options_scope = None
      del self._task_type_by_name[name]
      self._ordered_task_names = [x for x in self._ordered_task_names if x != name]
    else:
      raise GoalError('Cannot uninstall unknown task: {0}'.format(name))
976391
def cancel():
  
  task_id = request.form['id']
  task = Task.query.get(task_id)

  if not task:
    return json.dumps({
      'status': 'success',
      'id': None,
    })

  task.delete()

  if task.active:
    current_app.scheduler.cancel(task_id)

    code = task.code
    other_task = Task.query.filter_by(code=code).order_by('interval').first()
    if other_task:
      other_task.active = True
      other_task.save()
      current_app.scheduler.schedule({
        'id': other_task.id,
        'code': other_task.code,
        'interval': other_task.interval
      })

  return json.dumps({
    'status': 'success',
    'id': task_id,
  })
1065931
def remove(self):
        

        directory = self._directory()
        assert isinstance(directory, Directory)
        directory._fileDeleted(self)
1295148
def delete(self, item_id):
        
        try:
            response = self._request("tasks/delete/{id}".format(id=item_id))

            if response.status_code == 200:
                return True

        except sandboxapi.SandboxError:
            pass

        return False
637343
def _delete_stale(self):
        
        for name, hash_ in self._stale_files.items():
            path = self.download_root.joinpath(name)
            if not path.exists():
                continue
            current_hash = self._path_hash(path)
            if current_hash == hash_:
                progress_logger.info('deleting: %s which is stale...', name)
                path.unlink()
                self._stale_deleted += 1
                while True:
                    path = path.parent
                    if path == self.download_root or list(path.iterdir()):
                        break
                    progress_logger.info('deleting: %s which is stale..', path.relative_to(self.download_root))
                    path.rmdir()
            else:
                progress_logger.error('Not deleting "%s" which is in the lock file but not the definition '
                                      'file, however appears to have been modified since it was downloaded. '
                                      'Please check and delete the file manually.', name)
                raise GrablibError('stale file modified')
1173710
def delete!(request_options = {})
      res = delete(request_options)
      wait_task(res['taskID'], WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY, request_options)
      res
    end
77068
def remove(self, task_cls):
		
		registry_tag = task_cls.__registry_tag__
		if registry_tag in self.__registry.keys():
			self.__registry[registry_tag] = \
				list(filter(lambda x: x != task_cls, self.__registry[registry_tag]))
			if len(self.__registry[registry_tag]) == 0:
				self.__registry.pop(registry_tag)
387609
def delete_if_exists(self, **kwargs):
        
        try:
            self.get(**kwargs).blocking_delete()
            return True
        except ObjectDoesNotExist:
            return False
372689
def cleanup(self):
        
        if self.transport:
            self.transport.close()
            self.transport = None
        if self.task:
            self.task.cancel()
            self.task = None
928218
def PopTask(self):
    
    try:
      _, task = heapq.heappop(self._heap)

    except IndexError:
      return None
    self._task_identifiers.remove(task.identifier)
    return task
1049913
def remove(self, task_name):
        

        try:
            task_dir = self._get_task_dir(task_name)
            shutil.rmtree(task_dir)
            return True

        except OSError:
            return False
548056
def _AbandonQueuedTasks(self):
    
    # Abandon all tasks after they're identified so as not to modify the
    # dict while iterating over it.
    tasks_to_abandon = []
    for task_identifier, task in iter(self._tasks_queued.items()):
      logger.debug('Abandoned queued task: {0:s}.'.format(task_identifier))
      tasks_to_abandon.append((task_identifier, task))

    for task_identifier, task in tasks_to_abandon:
      self._tasks_abandoned[task_identifier] = task
      del self._tasks_queued[task_identifier]
1156124
private void moveTaskOutputs(TaskAttemptContext context,
                               FileSystem fs,
                               Path jobOutputDir,
                               Path taskOutput) 
  throws IOException {
    TaskAttemptID attemptId = context.getTaskAttemptID();
    context.progress();
    if (fs.isFile(taskOutput)) {
      Path finalOutputPath = getFinalPath(jobOutputDir, taskOutput, 
                                          workPath);
      if (!fs.rename(taskOutput, finalOutputPath)) {
        if (!fs.delete(finalOutputPath, true)) {
          throw new IOException("Failed to delete earlier output of task: " + 
                                 attemptId);
        }
        if (!fs.rename(taskOutput, finalOutputPath)) {
          throw new IOException("Failed to save output of task: " + 
        		  attemptId);
        }
      }
      LOG.debug("Moved " + taskOutput + " to " + finalOutputPath);
    } else if(fs.getFileStatus(taskOutput).isDir()) {
      FileStatus[] paths = fs.listStatus(taskOutput);
      Path finalOutputPath = getFinalPath(jobOutputDir, taskOutput, workPath);
      fs.mkdirs(finalOutputPath);
      if (paths != null) {
        for (FileStatus path : paths) {
          moveTaskOutputs(context, fs, jobOutputDir, path.getPath());
        }
      }
    }
  }
335296
def task_completed(task_id):
    

    tasks = get_tasks(task_id=task_id)
    completed_states = ('TASK_FINISHED',
                        'TASK_FAILED',
                        'TASK_KILLED',
                        'TASK_LOST',
                        'TASK_ERROR')

    for task in tasks:
        if task['state'] in completed_states:
            return True

    return False
327489
def _task_file_exists(self, task_fs):
        
        for filename in ["task.{}".format(ext) for ext in self.get_available_task_file_extensions()]:
            if task_fs.exists(filename):
                return True
        return False
361044
def reset(self):
        

        logger.debug('Resetting task {0}'.format(self.name))

        self.stdout_file = os.tmpfile()
        self.stderr_file = os.tmpfile()

        self.stdout = ""
        self.stderr = ""

        self.started_at = None
        self.completed_at = None
        self.successful = None

        self.terminate_sent = False
        self.kill_sent = False
        self.remote_failure = False